RALEIGH, N.C. (AP) — A judge ruled Friday that two students and an employee must be allowed to use restrooms matching their gender identity at University of North Carolina campuses, and he said they have a strong chance of proving the state’s bathroom-access measure violates federal law.

U.S. District Judge Thomas Schroeder temporarily blocked the University of North Carolina from making the three plaintiffs follow the restroom provision of the so-called HB2 law as the larger case makes its way to trial in November. His final decision on the law won’t come until after that trial.

Passed in March, HB2 requires transgender people to use the restrooms in schools and many public buildings that correspond to the sex on their birth certificates, rather than their gender identity. It also excludes gender identity and sexual orientation from statewide antidiscrimination protections.

The state’s Republican leaders argue the law is needed to protect privacy and safety by keeping men out of women’s restrooms. Transgender residents challenging the law argue that restroom safety is protected by existing laws, while the North Carolina measure is harmful and discriminatory.

In his ruling Friday, Schroeder wrote that the three plaintiffs in the lawsuit “are likely to succeed” in their arguments that HB2 violates Title IX, a federal law prohibiting discrimination on the basis of gender in educational institutions.

However, he said they haven’t shown they are likely to succeed on a claim that the law violates their constitutional equal protection rights, and he reserved judgment on another constitutional claim related to due process.

Rebuffing arguments by the law’s defenders, Schroeder also noted that existing laws already protect people’s privacy in restrooms.

“North Carolina’s peeping and indecent exposure statutes continue to protect the privacy of citizens regardless of” the bathroom provision, Schroeder wrote, “and there is no indication that a sexual predator could successfully claim transgender status as a defense against prosecution under these statutes.”

He said that while his injunction shouldn’t pose any hardship to the state leaders seeking to defend the law, failing to block the restroom provision “would cause substantial hardship to the individual transgender Plaintiffs, disrupting their lives.”

The plaintiffs challenging the law include a student at UNC’s Greensboro campus, an employee at its Chapel Hill campus and a high school student at the state School of the Arts, which is also run by the university system.

The UNC employee, Joaquin Carcano, issued a statement that the judge’s decision represents an important step toward defeating the law that has forced him to go far from his office to use a restroom.

“Today, the tightness that I have felt in my chest every day since H.B. 2 passed has eased. But the fight is not over: we won’t rest until this discriminatory law is defeated,” he said.

The American Civil Liberties Union, which represents the transgender plaintiffs, and the U.S. Justice Department both argued for a preliminary injunction to block the restroom provision of the law. Defending the law are Republican Gov. Pat McCrory, Republican legislative leaders and a citizens group.

Chris Brook, legal director of the ACLU of North Carolina, said the ruling gives the challengers momentum as the trial date nears.

“What we will see in the months to come, as this ruling forecasts, is that HB2 can’t be squared with Title IX and can’t be enforced at institutions that receive federal education funds,” Brook said.

Several cases seeking to challenge or defend the law were assigned to Schroeder, while another case is pending in a separate federal court.

North Carolina Senate leader Phil Berger and House Speaker Tim Moore, who have hired private attorneys to defend the law after the state’s Democratic attorney general declined to do so, issued a statement maintaining that the law represents “commonsense protections to keep grown men out of bathrooms and showers with women and young girls.”