A federal appeals court on Tuesday sided with a transgender teen who is suing his school over the right to use the boys bathroom.

In a 2-to-1 decision, the Fourth Circuit Court of Appeals in Richmond ordered a lower court to rehear a lawsuit filed by Gavin Grimm, a junior at Gloucester High School in Virginia who came out male in his sophomore year.

The court's majority deferred to the U.S. Department of Education's position on the issue, The New York Times reported. The agency has said that barring transgender students from using the bathrooms that match their gender identities amounts to a violation of Title IX.

“At the heart of this appeal is whether Title IX requires schools to provide transgender students access to restrooms congruent with their gender identity,” the court wrote. “We conclude that the Department's interpretation of its own regulation … as it relates to restroom access by transgender individuals, is … to be accorded controlling weight in this case.”

The ruling is likely to affect events in North Carolina, which is facing a backlash after barring transgender people in public institutions from using the bathroom that corresponds with their gender identity.

The Fourth Circuit oversees courts in five states, including North Carolina.