A federal 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, a judicial rebuke that transgender rights advocates hailed as a victory.

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 trial.

Passed in March, HB2 requires transgender people to use 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 say that restroom safety is protected by existing laws, while the North Carolina measure is harmful and discriminatory.

North Carolina Senate leader Phil Berger and House Speaker Tim Moore issued a statement maintaining that the law represents “commonsense protections to keep grown men out of bathrooms and showers with women and young girls” and saying they were pleased that the ruling only extended to the three plaintiffs.

In Friday’s ruling, Schroeder wrote that the challengers “are likely to succeed” in their arguments that HB2 violates Title IX, a federal law prohibiting gender discrimination in educational institutions.

However, he said plaintiffs 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.