FORT WORTH, Tex.—A federal judge has ruled in favor of 13 states against President Barack Obama’s directive that public schools must allow students and adults to enter whatever bathrooms or showers they choose, a policy imposing transgenderism on the nation’s schools.

Title VII of the Civil Rights Act of 1964 forbids any employer from discriminating on the basis of sex. In 1972, Congress added Title IX, requiring all schools receiving federal funds—which includes every public school nationwide—to provide separate facilities of equal quality for both male and female students.

On May 13, 2016, the Obama administration’s Department of Education sent a letter to every school system in America, informing them that regulations implementing Title IX require all schools to allow all children and adults to use whichever bathroom and shower facilities they choose to identify with, regardless of whether that gender identity is the same as their biological sex. This corresponded with other federal pronouncements reiterating that all employers are subject to this same requirement under Title VII.

As an example, this means that when a 14-year-old high school freshman girl goes to the girls’ locker room to shower, an 18-year-old boy (now an adult) who is a senior at that school has the legal right to use the shower right next to her while she’s showering, so long as he says he’s identifying as a female on that particular day. (One of the new gender categories is “gender fluid,” meaning that a person can change gender identities from day to day.)

The administration has specified that requiring biological boys or men to use separate facilities, or to use the same facility at a different time of day than when females are using them, would be illegal discrimination.

This directive is also a threat to the religious liberty of Christian schools and universities nationwide (as well as other faiths), many of which receive federal Title IX funding, and would force them to either forfeit funding or violate the teachings of their faith.

In response, 13 states—led by Texas and joined by a couple school districts in Texas and Arizona—sued the U.S. Departments of Education, Justice, Labor, and other federal agencies in U.S. District Court for the Northern District of Texas. The plaintiff states argued that Title VII and Title IX refer only to biological sex, and therefore that these federal orders violate the requirements of the Administrative Procedure Act (APA) and are contrary to federal law.

The plaintiffs began by seeking a preliminary injunction to block Obama’s transgender directive while the lawsuit is ongoing. A federal judge granted that injunction on Aug. 21.

Judge Reed O’Connor of the Northern District of Texas began his order by noting that Obama’s requirements “apply to the youngest child attending school and continues for every year throughout each child’s educational career.”

Judge O’Connor went on to write that “the Constitution assigns these policy choices to the appropriate elected and appointed officials.” But those officials “must follow the proper legal procedure,” and so his ruling in this lawsuit is focused solely on whether the Obama administration followed the law.

The court rejected all of the Obama administration’s procedural arguments. Lawyers for the federal government argued that the plaintiffs lacked standing to bring suit, and that the APA did not apply to this case because the transgender directive was not a “final agency action.” The court ruled that the transgender directive is a form of federal regulation governed by the APA.

Reaching the merits of the case, the court ruled that the plaintiffs had a substantial likelihood of ultimate success in the lawsuit. That court held that Obama’s transgender directive is a “substantive rule” that must be opened up to the general public for a period of notice and public comment before it can take effect with force of law. The court also held that even if the regulation had gone through the notice-and-comment process, it would still be illegal because it violates the meaning of “sex” in Title VII and Title IX, making the directive contrary to law.

The court additionally held that a preliminary injunction was appropriate while this lawsuit is ongoing because otherwise the transgender directive would cause irreparable harm to the states, that on balance such an injunction was fair to all concerned, and that an immediate halt to the transgender policy was in the public interest.

The court specified that its order is binding on every agent of the federal government nationwide. “This preliminary injunction shall be binding on Defendants and any officers, agents, servants, employees, attorneys, or other persons in active concert or participation with Defendants.”

The Obama Justice Department will likely immediately appeal this preliminary injunction to the U.S. Court of Appeals for the Fifth Circuit. Since there are two other similar lawsuits across the country confronting this issue—one in North Carolina and the other in the Great Plains states—this issue could also go before the U.S. Supreme Court on an expedited basis.

The case is Texas v. United States.

Ken Klukowski is senior legal editor for Breitbart News. Follow him on Twitter @kenklukowski.