In a landmark ruling, the 4th Circuit Court of Appeals held on Tuesday that federal law bars public schools from denying trans students access to the bathroom that aligns with their gender identity. The 2–1 decision afforded deference to the federal government’s interpretation of existing law to protect trans students from discrimination. Under that interpretation, the court held, public schools cannot exclude trans students from the bathroom. The ruling puts North Carolina’s new bathroom restrictions in direct conflict with federal law and clear judicial precedent.

At the heart of the 4th Circuit’s ruling is a single provision of Title IX of the Education Amendments of 1972. Title IX bars sex discrimination, which the agency interprets to encompass gender identity discrimination. Federal courts must defer to “reasonable” agency interpretations of the law. So the 4th Circuit explored the concept of “sex,” noting that “a hard-and-fast binary division on the basis of reproductive organs” is “not universally descriptive.” Rather, dictionaries in use when Congress passed Title IX defined sex as “the sum of the morphological, physiological, and behavioral peculiarities of living beings … that is typically manifested as maleness and femaleness.” The complexity of sex, combined with this qualifier (“typically”), indicates that “sex” encompasses the gap between the binary, and the broader concept of gender identity.

This decision overturns a federal judge’s ruling to the contrary and effectively ensures that a trans Virginia student will win his case against the school that barred him from the bathroom. Perhaps more importantly, the ruling casts serious doubt on the validity of North Carolina’s new anti-LGBTQ law, which forbids all trans public school students from using the correct facilities. (North Carolina, like Virginia, falls within the 4th Circuit, along with Maryland, West Virginia, and South Carolina.) Although the University of North Carolina’s anti-gay president has declared that she will enforce the law against trans students, the 4th Circuit’s decision makes clear that such enforcement would be illegal. If UNC (and other North Carolina schools) move forward with their plan to discriminate against trans students, they stand to lose $4.5 billion in Title IX funding.

“Today’s ruling makes plain that the North Carolina legislature violated Title IX by discriminating against trans students and forcing them to use the wrong restroom at school,” Chris Brook, legal director of the ACLU of North Carolina, told me. “The state should do what we’ve been calling on them to do for weeks now: Repeal HB2.”

Just a day before the 4th Circuit handed down its decision, a Tennessee lawmaker killed the state’s bathroom bill. This week is shaping up to be an unprecedentedly good one for trans students in America.

Update, April 19, 2016: This post has been updated with a comment by the ACLU of North Carolina’s legal director.