A federal court late Sunday night barred the Obama administration from enforcing a broad set of guidelines instructing states and localities on how to accommodate transgender students attending public schools ― including their need to use restrooms that align with their gender identity.

U.S. District Judge Reed O’Connor, of the Northern District of Texas, enjoined the policies nationally and blocked the federal government from conducting any litigation or attempting to bring school districts in compliance with them.

The guidelines, released jointly by the Departments of Justice and Education in May, were an effort to extend existing civil rights protections to transgender students, who often face barriers locally that stigmatize them, including harassment by classmates or incorrect record-keeping by school administrators.

“Taken together, we hope these new resources provide clarity for everyone ― from state and local leaders to educators to students and families ― about how to create a safe, welcoming and supportive learning environment for every student,” Vanita Gupta and Catherine Lhamon, the civil rights heads at DOJ and DOE who addressed the guidelines to school districts nationwide, said at the time.

But weeks after the move, Texas led a group of 13 states in suing the federal government to stop its implementation, arguing that the Obama administration was overstepping its authority under Title IX, one of a number of anti-discrimination statutes that courts and the government have read to cover gender identity discrimination.

“These new mandates, putting the federal government in the unprecedented position of policing public school property and facilities ... run roughshod over clear lines of authority, local policies, and unambiguous federal law,” the states said in a July motion seeking a nationwide injunction against the federal guidance.

O’Connor’s ruling agreeing to the injunction is meant to ease fears that the guidance would disrupt the coming school year in Texas, which kicked off Monday.

Permitting the definition of sex to be defined in this way would allow Defendants to create de facto new regulation by agency action without complying with the proper procedures. From the ruling of U.S. District Judge Reed O’Connor

Dena Iverson, a spokeswoman for the Department of Justice, said in a short statement that the government is disappointed in the ruling and is considering its next steps.

Under Title IX, every state and locality that receives federal funding for schools must agree to abide by it. Congress specifically designed the law to prevent sex discrimination in education settings, but a series of rulings and regulations have interpreted it to also cover discrimination against transgender individuals.

Texas and other states ― including North Carolina, which is embroiled in its own legal battle with DOJ over a controversial anti-trans bathroom law ― have argued that this interpretation goes beyond what the law says, presenting them with a “Hobson’s choice” between compliance or risking losing millions in federal funding.

“The Joint Letter is an unlawful attempt to rewrite the terms attached to Title IX monies,” wrote the attorneys general for the states in their July motion. “Because Congress did not provide clear notice that funds subject to Title IX were linked to an ‘all comers’ restroom and intimate areas policy — and in fact allowed separate-sex facilities — the Joint Letter is unconstitutional.”

O’Connor did not go that far in his ruling, but stated that the Obama administration nonetheless should have gone through the proper administrative channels ― including a period of notice and comment for the public ― before sending them to states and localities.

“Permitting the definition of sex to be defined in this way would allow Defendants to create de facto new regulation by agency action without complying with the proper procedures,” O’Connor said.

But critics of Texas’ legal tactics ― which resemble its lawsuit against the Obama administration over its executive actions on immigration ― say that the state manufactured a controversy where there was none.

A day after the states announced their lawsuit, The Texas Tribune reported that the office of Texas Attorney General Ken Paxton (R) had actually shopped around an anti-trans bathroom policy to a small Texas school district. That district would later become the nominal plaintiff in the lawsuit.

Paul J. Weber/Associated Press The Harrold Independent School District -- which has 100 students, none of whom is transgender -- is the unlikely battleground over whether U.S. schools must provide bathroom rights to transgender students.

Joining Texas in its legal efforts are the states of Alabama, Wisconsin, West Virginia, Tennessee, Arizona, Maine, Oklahoma, Louisiana, Utah, Georgia, Mississippi and Kentucky. Ten other states, led by Nebraska, are seeking similar relief in a separate lawsuit.

Paxton, who led the effort, was pleased with the issuance of the injunction, which he said is a response to the Obama administration “attempting to rewrite the laws enacted by the elected representatives of the people.”

“That cannot be allowed to continue, which is why we took action to protect States and School Districts, who are charged under state law to establish a safe and disciplined environment conducive to student learning,” Paxton said in a statement Monday.

The American Civil Liberties Union and its local Texas chapter, plus Lambda Legal, the National Center for Lesbian Rights, the Transgender Law Center, and GLBTQ Legal Advocates & Defenders issued a joint statement condemning how the injunction could affect transgender students. The groups had filed a legal brief in the case in support of the government.

“A ruling by a single judge in one circuit cannot and does not undo the years of clear legal precedent nationwide establishing that transgender students have the right to go to school without being singled out for discrimination,” the groups said, adding that the decision “targets a small, vulnerable group of young people ― transgender elementary and high school students ― for potential continued harassment, stigma and abuse.”

The administration is expected to seek an emergency stay of O’Connor’s order from the U.S. Court of Appeals for the 5th Circuit, which could then lead to a further appeal to the U.S. Supreme Court.

Earlier this month, the high court stepped into the debate over transgender rights and bathroom access when it agreed to temporarily put on hold a ruling in favor of a trans student in Virginia who sued his school district after it enacted a policy limiting bathroom use according to each person’s biological sex.

This post has been updated with more details from the ruling and responses to the injunction.