A federal court ruled against a Virginia school district on Tuesday, holding that federal law protects a transgender student who sought to use the boys’ bathroom at his school.

The ruling is a victory for Gavin Grimm — a transgender male — who began his legal fight four years ago and has since graduated from the school. The court denied a motion filed by the school district to dismiss Grimm’s lawsuit.

Grimm’s lawyers at the American Civil Liberties Union argued that Title IX — a federal law that prohibits discrimination on the basis of sex in federally funded education programs — includes discrimination based on gender identity.

“After full consideration of the facts presented and the compelling scope of relevant legal analyses, the Court concludes that Mr. Grimm has sufficiently pled a Title IX claim of sex discrimination under a gender stereotyping theory,” wrote Judge Arenda L. Wright Allen, of the US District Court for the Eastern District of Virginia.

A federal appeals court based in Chicago issued a similar ruling in a different challenge in May 2017.

Grimm’s case was appealed to the Supreme Court, which kicked it back into the lower courts. The previous court ruling was vacated after the Department of Education revoked President Barack Obama’s guidance that Title IX covered transgender people last year.

In a statement Tuesday night Grimm said, “I feel an incredible sense of relief. After fighting this policy since I was 15 years old, I finally have a court decision saying that what the Gloucester County School Board did to me was wrong and it was against the law. I was determined not to give up because I didn’t want any other student to have to suffer the same experience that I had to go through.”

In response, the Gloucester County School Board said it believes its policy took into account all students’ interests.

“The School Board is aware of the District Court’s decision denying the motion to dismiss Plaintiff’s Amended Complaint,” the statement read. “The School Board continues to believe that its resolution of this complex matter fully considered the interests of all students and parents in the Gloucester County school system.”