A federal judge ruled Friday that a Virginia school district's policy barring a male transgender student from using the boys bathrooms violates the U.S. Constitution, an important victory for transgender rights advocates in a closely watched case.

In a 28-page ruling, Judge Arenda Wright Allen of the U.S. District Court in Norfolk, Va., said that the school district's policy violated the rights of Gavin Grimm, a former student.

"There is no question that the board's policy discriminates against transgender students on the basis of their gender nonconformity," Wright Allen wrote. "Transgender students are singled out, subjected to discriminatory treatment, and excluded from spaces where similarly situated students are permitted to go."

School bathroom policies vary, sometimes district by district, across the country. Many in recent years have faced contentious legal challenges over which bathrooms transgender students should be allowed to use. Grimm's lawsuit against Gloucester County Public Schools in Virginia is among the best known.

Wright Allen's ruling echoes those in several other courts that have recently ruled in favor of allowing transgender students to use bathrooms corresponding to the gender they identify with.

Yet nationwide, the question is far from resolved. The Supreme Court this year chose not to take up an appeal in a similar case. And it is not clear that the Supreme Court would take up any such cases until there are conflicting opinions in lower appellate courts, according to Joshua Block, Grimm's lawyer. To date, there have not been any, he said.

Grimm, 20, attended Gloucester High School from 2013 to 2017. The district School Board had maintained that Grimm's "biological gender" was female, prohibiting administrators from allowing him to use the boys restrooms.

Grimm, who wrote an op-ed essay in The New York Times in June about his experiences growing up, said in an interview that Friday's ruling was "wonderful."

"It was certainly a victory for the trans community," he said.

Block said the ruling applied only to Grimm, but it would most likely become "persuasive precedent" in other cases. He said the school district's policy was still in effect.

"If another student is subjected to this discriminatory policy, that student can go to court and has this decision to point to right away," said Block, a senior staff attorney with the American Civil Liberties Union. "Other school districts in Virginia and around the country have been looking to see what happens with this case."

A lawyer for Gloucester County Public Schools declined to comment on the decision Friday.

A federal judge in Oregon said last year that forcing transgender students to use bathrooms and locker rooms inconsistent with their gender identity would harm transgender students. An appellate court in Pennsylvania ruled in July 2018 in favor of a policy that supported transgender students, despite a challenge from other students who said sharing bathrooms with transgender students would infringe on their rights to privacy, among other laws.

"There has been striking uniformity over the past three years where judges who are confronted with real trans students, and real evidence, are finding that there is simply no basis for treating boys and girls who are transgender differently than other boys and girls," Block said.

Wright Allen's ruling Friday culminates a lengthy legal process in Grimm's case.

He sued in July 2015. The School Board argued in essence that its policy, adopted in 2014, was valid because Title IX of the Education Amendments of 1972 allows for claims only on the basis of sex, rather than gender identity, and that its policy did not violate the equal protection clause.

Partway through the proceedings, in March 2017, President Donald Trump's administration rescinded protections for transgender students.

The Supreme Court then vacated a prior appeals court decision in favor of Grimm and sent the case back to the federal appeals court in Virginia for further consideration in light of the new guidance from the Trump administration. The case was later returned to the District Court.

In May 2018, Wright Allen, who was appointed to the bench by President Barack Obama, denied a motion by the School Board to dismiss the lawsuit.

Gillian Branstetter, a spokeswoman for the National Center for Transgender Equality, called Friday's ruling "extremely important."

"For many people, in a cultural sense, the Gavin Grimm case is the case, and not merely the case governing the right of transgender students, but the case centering on transgender rights, period," she said.

Buy It Now!