Transgender student Gavin Grimm poses on his front porch during an interview at his home in Gloucester, Va. on Aug. 25, 2015. U.S. District Court Judge Robert G. Doumar ruled Thursday that the Gloucester County School Board must allow Grimm to use the bathroom that matches his gender identity while the case is being litigated in court. (Steve Helber/AP)

A federal judge has ordered a school board in rural Virginia to give a transgender student, who was born female but identifies as male, access to the boys’ bathroom while his discrimination lawsuit against the school board proceeds.

Gavin Grimm, a 17-year-old rising senior at Gloucester High in Gloucester County, Va., sued the school board last year after it passed a policy requiring students to use bathrooms based on their “biological gender.” He alleged that the policy barring him from the boys bathroom violated his civil rights and ran afoul of Title IX, which bans sex discrimination in public schools.

The U.S. Court of Appeals for the 4th Circuit sided with the teen in April, deferring to the Obama administration’s position that transgender students are entitled to use bathrooms that match their gender identity.

The judges also ruled that the lower court should reconsider a request that would have allowed Grimm to use the boys’ bathroom at his high school while the case is pending, saying the judge had used the wrong standard. The school board has said it will ask the U.S. Supreme Court to hear the case.

The Fourth Circuit is the highest court thus far to weigh in on the question of whether transgender students have the right to use school bathrooms coinciding with their gender identity, and the ruling was viewed as an important development in the battle over school bathrooms, seen as the latest frontier for LGBT rights.

In May, the U.S. Education Department issued a guidance letter directing schools to allow transgender students to use the bathrooms corresponding with their gender identity, a move that sparked backlash and a lawsuit by 11 states that argued the administration had overstepped its authority.

U.S. District Judge Robert Doumar, who denied Grimm’s petition last year, this time granted his request to use the boys’ bathroom while his case proceeds after weighing the ruling from the appeals court. In the 1½ -page order, Doumar specified that the injunction allows Grimm to use the boys’ bathroom but not the locker room.

Attorney Joshua Block of the American Civil Liberties Union, who is representing Grimm, said the injunction marked a concrete victory for the teen who will have access to the boys’ bathroom his senior year of high school, even if the lawsuit continues long after he graduates.

“When he goes back to school this fall for his senior year, he’ll be able to use the bathroom just like any other boy,” Block said.

Grimm, who said he feels “dysphoric” every time he is forced to use a separate bathroom at school, said he was “elated” at the judge’s order.

In his lawsuit, Grimm said he used the boys’ bathroom for several weeks without incident before the school board passed a policy banning him from it.

“After nearly two years of humiliation and intense struggle, equality has finally prevailed. Now hopefully other transgender people will not have to face this type of discrimination,” Grimm said.

The school board issued a statement through its attorney, saying that it “understands the implications of the order and will continue to defend its reasonable and nondiscriminatory solution to this issue at the Supreme Court and trial court levels.”

This story has been updated.