The supreme court on Wednesday blocked a court order giving a transgender student access to the boys’ bathroom at his Virginia high school, in what is the high court’s first ruling on an increasingly contentious topic.

The ruling permits the Gloucester county school board to continue barring Gavin Grimm, a trans boy, from using the boys’ restroom until the supreme court decides whether or not to hear Grimm’s challenge to the school board.

The decision is a major setback for the teenager and will bar him from using the bathroom consistent with his gender identity when he begins his senior year of high school.

In April, Grimm won a key victory before the fourth circuit court of appeals that granted him access to the boy’s bathroom.

At the time, the circuit court was the highest court in the country to have weighed in on the issue of transgender access to spaces, such as bathrooms and locker rooms, that are segregated by gender. Trans rights supporters hailed Grimm’s win was hailed as a key victory. In July, the circuit court rejected a plea from the Gloucester County school board to stay its order while the lawsuit continued.

In response, the school board appealed to the supreme court, arguing that allowing a trans student to use a bathroom that didn’t correspond with his or her “biological” gender would cause irreparable harm by violating other students’ privacy.

The court’s four conservative justices and Justice Stephen Breyer voted for Wednesday’s ruling on the basis that it “will preserve the status quo” as Grimm’s court fight continues. Breyer joined the majority “as a courtesy”.

Justices Ruth Bader Ginsburg, Sonia Sotomayor and Elena Kagan indicated that they would have allowed Grimm to have access to the boy’s restroom while the case is on appeal.

“We are disappointed that the court has issued a stay and that Gavin will have to begin another school year isolated from his peers and stigmatized by the Gloucester County school board just because he’s a boy who is transgender,” said Joshua Block, an attorney with the American Civil Liberties Union who is representing Grimm. “We remain hopeful that Gavin will ultimately prevail.”

Grimm’s lawsuit is just one of many asking whether federal law protects students like him from discrimination.

Both the Department of Justice and the Department of Education have ruled that Title IX, a federal law banning gender discrimination, protects the right of transgender individuals to use the bathrooms and restrooms consistent with their gender identity without restriction. In May, Barack Obama announced that his administration expected all public schools to comply or risk the loss of millions in federal education funds.

But a growing number of states and schools have revolted against those mandates in a surge of legal challenges. Nearly two dozen states in two separate lawsuits are suing the Obama administration, claiming the Title IX definition of gender bias does not establish protections for transgender individuals. Separately, North Carolina and the federal government are embroiled in a massive legal battle over that state’s broad restrictions, which apply to restrooms and locker rooms in any public spaces.

Grimm sued the Gloucester County school board in 2015. The junior high school student, who was assigned female at birth, started the school year having transitioned: school documents identified Grimm as male and he went by Gavin in class.

For seven weeks, Grimm also used the boy’s bathroom without any interference. But the school board changed its policy when parents – and some adults with no children in the Gloucester county school system – complained. A series of virulent public meetings followed, where residents called Grimm a “freak” and compared him to a dog.

The board ultimately forced Grimm to use standalone unisex bathrooms installed specifically for his use. The experience, Grimm has said, was “humiliating”.

US district Judge Robert Doumar dismissed Grimm’s lawsuit in September, saying Title IX “allows schools to maintain separate bathrooms based on sex” and “under any fair reading, ‘sex’ … clearly includes biological sex” that individuals are assigned at birth.

But the fourth circuit rejected that argument and ruled that Title IX extends to transgender individuals.

“The uncontroverted facts before the district court demonstrate that as a result of the Board’s restroom policy, [Grimm] experiences daily psychological harm that puts him at risk for long-term psychological harm,” one of the circuit judges, Andre Davis, wrote in his concurring opinion.