NORFOLK, Va. — A federal judge in Virginia ruled Friday that a school board's transgender bathroom ban discriminated against a former student, Gavin Grimm, the latest in a string of decisions nationwide that favor transgender students who faced similar policies.

The order issued by U.S. District Judge Arenda Wright Allen in Norfolk is a major victory for the American Civil Liberties Union and for Grimm. His four-year lawsuit was once a federal test case and had come to embody the debate about transgender student rights.

The issue remains far from settled as a patchwork of differing policies governs schools across the nation. More court cases are making their way through the courts.

The Gloucester County School Board's policy required Grimm, a transgender male, to use girls' restrooms or private bathrooms. The judge wrote that Grimm's rights were violated under the U.S. Constitution's equal protection clause as well as under Title IX, the federal policy that protects against gender-based discrimination.

"There is no question that the Board's policy discriminates against transgender students on the basis of their gender noncomformity," Allen wrote.

"Under the policy, all students except for transgender students may use restrooms corresponding with their gender identity," she continued. "Transgender students are singled out, subjected to discriminatory treatment, and excluded from spaces where similarly situated students are permitted to go."

Allen's ruling requires the school board to update the gender on Grimm's high school transcripts.

The judge also acknowledged that the board had the "unenviable responsibility" of navigating challenges that were unimaginable a generation ago.

"There can be no doubt that all involved in this case have the best interests of the students at heart," Allen added.

Grimm graduated in 2017 from Gloucester High School, located in a mostly rural area about 60 miles east of Richmond and near the Chesapeake Bay. Now 20 and living in California, he said by phone that the judge's order was "beautiful."

Grimm said he felt a sense of relief but would continue to fight the case if the school board appeals.

"My case has given me something of a platform that I intend to use, as long as I have it available to me, for trans education and advocacy," he added.

David Corrigan, the attorney for the Gloucester County School Board, declined to comment in an email to The Associated Press.

Corrigan had argued in court last month that Grimm remained female. He said gender is not a "societal construct" and that it doesn't matter that Grimm underwent chest reconstruction surgery and hormone therapy.

The judge's ruling will likely strengthen similar claims of discrimination made by students in eastern Virginia. It could have a greater impact if the case goes to an appeals court that oversees Maryland, West Virginia and the Carolinas.

Allen's ruling joins others that have been favorable to transgender students in states that include Maryland, Pennsylvania and Wisconsin. But differing policies are still in place in schools across the country, Harper Jean Tobin, policy director for the National Center for Transgender Equality, told The Associated Press last month.

Gary McCaleb, senior counsel for the conservative Christian group Alliance Defending Freedom, said last month that the issue is far from resolved.

McCaleb cited a federal discrimination complaint his organization filed in June that says a Connecticut policy on transgender athletes is unfair because it allows transgender girls to consistently win track and field events.

He also said a pending U.S. Supreme Court case involving a transgender woman who was fired by a Michigan funeral home could affect school bathroom policies.

Grimm's lawsuit became a federal test case when it was supported by the administration of then-President Barack Obama and scheduled to go before the Supreme Court in 2017.

But the high court hearing was canceled after President Donald Trump rescinded an Obama-era directive that students can choose bathrooms corresponding with their gender identity.

Follow NBC Out on Twitter, Facebook & Instagram