The rights of transgender student Gavin Grimm were violated when he was barred from using the boys’ restroom at his school, a federal judge ruled Friday. (Kristen Zeis/Daily Press (Newport News)/AP)

The constitutional rights of a transgender student were violated when he was barred from using the boys’ restroom at his Virginia high school, a federal judge ruled Friday.

The student, Gavin Grimm, said the ruling sent the message that “discrimination is not legal in America.” But the 20-year-old, who has graduated from the high school where he was banned from the boys’ restroom, acknowledged that the school system could appeal the decision, and it is “likely that this is not the end.”

“We deserve equal rights,” said Grimm, who is studying in California to be a teacher. “I’m going to be doing what I can to fight.”

Gloucester County School Board Chairman William “Jarret” Lee declined to comment Friday night. The board’s attorney, David P. Corrigan, could not be reached for comment.

But in court last month, attorneys for the Gloucester County School Board argued that gender is not a “societal construct” and that Grimm has not undergone sex reassignment surgery and should not be allowed to use the boys’ restroom.

Grimm sued after the school board in 2014 mandated that students use restrooms aligned with their “biological genders.” He argued that the policy violated the 14th Amendment’s equal-protection clause and Title IX, the law prohibiting discrimination on the basis of sex in schools that receive federal money.

The case ascended to the Supreme Court, which was scheduled to hear it in spring 2017. But the justices returned the case to a lower federal court after the Trump administration reversed Obama-era guidance that directed schools to allow students to use restrooms that aligned with their gender identity.

Last year, Judge Arenda L. Wright Allen declined to dismiss the case from the U.S. District Court for the Eastern District of Virginia. The two sides appeared in Allen’s courtroom last week to argue the case after talks to end the bathroom rule broke down earlier this year.

Allen, who struck down Virginia’s ban on same-sex marriage in 2014, rejected the Gloucester system’s argument that allowing transgender students to use the bathroom matching their gender identities caused privacy concerns for other students.

She found the policy harmed Grimm, who felt “stigmatized and isolated” when he had to use separate restrooms. Grimm avoided using the restroom at school and developed a urinary tract infection and experienced suicidal thoughts.

“The perpetuation of harm to a child stemming from unconstitutional conduct cannot be allowed to stand,” Allen wrote in her decision, which declared that Grimm’s rights were violated “on the day the policy was first issued” and until he left Gloucester High, in the Hampton Roads region.

Joshua Block, a senior attorney with the American Civil Liberties Union who is representing Grimm, heralded Allen’s ruling as a “complete victory.” The judge’s decision also directs the school system to change the gender on Grimm’s school records to male — he is currently listed as female.

Block said that because Grimm has graduated, the court doesn’t have the power to order the school to change its policy. But, he said, any student who is subjected to the rule will be able to “go right into court and point to this decision.”

“It’s going to have a major, positive impact, not only on the lives of trans kids in Gloucester County but throughout Virginia,” Block said.