WASHINGTON — A U.S. judge on Tuesday ruled that federal law protects a transgender student who fought all the way to the Supreme Court for the right to use a bathroom at a high school in Virginia that corresponded with his gender identity.

U.S. District Judge Arenda Wright Allen in Norfolk rejected a bid by the Gloucester County School Board to dismiss the civil rights lawsuit filed by student Gavin Grimm.

Gloucester County High School senior Gavin Grimm, a transgender student, speaks during a news conference in Richmond, Virginia, on March 6. Steve Helber / AP, file

The judge said Grimm has valid claims under a federal law, called Title IX of the Education Amendments of 1972, that bars discrimination on the basis of sex in education as well as the U.S. Constitution’s guarantee of equal protection under the law.

Grimm filed the suit in 2015 and graduated from high school last year.

Wright Allen rejected the school board’s argument that its policy was justified by the need to protect the privacy rights of students, saying that “preventing Mr. Grimm from using the boys’ restrooms did nothing to protect the privacy rights of other students, but certainly singled out and stigmatized Mr. Grimm.”

Grimm, 19, was assigned female at birth and now identifies as male. Grimm had sued the school board to win the right to use the public school’s boys’ bathroom.

Bathroom access has become a major issue in the battle over transgender rights, and Grimm’s suit has been the most prominent legal case on the subject.

“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,” Grimm, who is represented by the American Civil Liberties Union, said in a statement.

Wright Allen, whose ruling was similar to several others across the United States in favor of transgender students, said the parties should schedule a settlement conference within 30 days.

Grimm’s case had previously reached the Supreme Court and was set to be argued in March 2017 when President Donald Trump’s administration rescinded guidance previously issued by the administration of President Barack Obama regarding bathroom access for transgender students.

The Obama administration had told public schools nationwide to let transgender students use the bathroom of their choosing. The Supreme Court subsequently sent the case back to lower courts without issuing a ruling on the merits.

A spokesman for the school board could not immediately be reached for comment.

The school board’s former lawyer, Kyle Duncan, was recently appointed by Trump as a judge on the New Orleans-based 5th U.S. Circuit Court of Appeals.