The Obama administration was barred by a judge from enforcing a directive that U.S. public schools allow transgender students to use bathrooms and locker rooms according to their gender identity.

A federal judge in Fort Worth, Texas, on Sunday sided with Texas and 12 other states that argued the administration’s policy usurps local control and threatens students’ safety and privacy.

The use of public bathrooms and locker rooms by transgender people has become the latest front in civil rights struggles between social conservatives and the administration following battles over same-sex marriage and military service by openly gay members of the armed forces in which President Barack Obama has sided with gay-rights advocates.

 The ruling by U.S. District Judge Reed O’Connor came after the U.S. Supreme Court on Aug. 3 temporarily blocked an order that would let a transgender student use the boys’ bathrooms during his senior year at a Virginia high school.

In that case, the justices granted a request from the Gloucester County school board, which said the lower court order would have caused “severe disruption” when school started in September and likely prompted parents to transfer their children to other institutions. The district said boys’ restrooms were reserved for students who were “biological” males.

In the Texas case, the judge said his ruling was based on the administration failing to follow rule-making procedures and not underlying issues of students’ rights. With the preliminary injunction in place, the judge will now consider whether to make the order permanent.

The U.S. Department of Education published guidelines in May instructing schools to not discriminate on the basis of gender identity. The directive was issued days after the Justice Department sued North Carolina over a state law requiring residents to use public restrooms matching their gender at birth.

Difficult Balance

“This case presents the difficult issue of balancing the protection of students’ rights and that of personal privacy when using school bathrooms, locker rooms, showers, and other intimate facilities, while ensuring that no student is unnecessarily marginalized while attending school,” O’Connor said. “The resolution of this difficult policy issue is not, however, the subject of this order.”

O’Connor said his ruling doesn’t apply to disputes that are already in court, which would include the cases in North Carolina and Virginia. It also doesn’t apply to schools that already accommodate transgender students’ choice of bathrooms.

“If you’re already doing what I like to call the right thing and you are not discriminating against transgender students, this has no effect on your district,” said Kenneth Upton, a lawyer with the Lambda Legal Defense and Education Fund who wrote a friend-of-the-court brief on behalf of civil rights groups in the Texas case. “If you have a policy that doesn’t permit that, for now the federal government can’t come in and force you to do it.”

The injunction, for example, will not affect policies in New York City’s public schools, which since 2014 have allowed students and faculty members to choose bathrooms consistent with their gender expression, according to city Public Advocate Letitia James.

James, who also filed a friend-of-the-court brief in the Texas case, said in an e-mailed statement, “Such open and inclusive policies have safely existed in New York City for several years, demonstrating how thoughtful action can actually serve to protect our children, not harm them.”

O’Connor, who was nominated by former President George W. Bush and confirmed for the bench in 2007, last year put on hold a federal rule granting Family and Medical Leave Act benefits to same-sex couples after Texas filed a lawsuit. Three months after his order, the U.S. Supreme Court ruled in June 2015 that the Constitution guarantees a right to same-sex marriage.Texas Attorney General Ken Paxton said he was pleased with the ruling against what he called the Obama administration’s “latest illegal federal overreach.”

“This president is attempting to rewrite the laws enacted by the elected representatives of the people, and is threatening to take away federal funding from schools to force them to conform,” Paxton said in a statement.

The case is State of Texas v. U.S.A., 7:16-cv-00054, U.S. District Court, Northern District of Texas (Wichita Falls).