A federal court sided with a transgender teen on Tuesday, saying that a lower court should have deferred to the federal government's assertion that Title IX protects transgender students.

Gavin Grimm, 16, sued his school in Gloucester County, Va., after it decided that he would not be allowed to use the boys bathroom. After intense public debate, the school decided on a policy that provided boys and girls bathrooms that were limited to "corresponding biological genders." Later, the school also provided a unisex bathroom that Grimm could use.

Grimm, who was designated female but identifies as male, argued the policy violated Title IX of the Educational Amendments Act of 1972, which prohibits discrimination on the basis of sex in any educational program that gets federal funding. In 2015, the Department of Education issued a memo saying that when a school decides to treat students differently on the basis of sex, it "generally must treat transgender students consistent with their gender identity."

The U.S. Fourth Circuit Court of Appeals sided with Grimm, saying the lower court should have respected that interpretation.

In a statement, Grimm said he felt "relieved and vindicated" by the court's ruling.

"Today's decision gives me hope that my fight will help other kids avoid discriminatory treatment at school," Grimm said.

The American Civil Liberties Union of Virginia, which brought the case to court on behalf of Grimm in 2015, says this is the first time a federal court has affirmed that Title IX protects transgender students.

"Today's Fourth Circuit decision is a vindication for Gavin and a reinforcement of the Department of Education's policy." Joshua Block, a senior staff attorney at the ACLU Lesbian, Gay, Bisexual, and Transgender Project, said in a statement. "With this decision, we hope that schools and legislators will finally get the message that excluding transgender kids from the restrooms is unlawful sex discrimination."

Copyright 2016 NPR. To see more, visit http://www.npr.org/.