RICHMOND, Virginia — A U.S. appeals court on Tuesday ruled for a Virginia transgender student seeking access to the bathroom of his gender identity in a case that could affect the national bathroom wars playing out between gay rights activists and social conservatives.

The ruling by the U.S. Fourth Circuit Court of Appeals sent back to a lower court the widely watched case that considered whether transgender students are protected by the 1972 Title IX Act, which prohibits sex-based discrimination by schools receiving federal funding.

Student Gavin Grimm was barred from using the boys bathroom at his high school in Gloucester County, Virginia. Grimm was born a female but identifies as a male.

Maine Gov. Paul LePage and other conservatives had filed a brief asking the court to block the challenge to the school district’s bathroom-use policy, arguing the student is “biologically of the female sex.”

After drawing community complaints for allowing Grimm to use the boys bathroom, the school district approved a policy in December 2014 requiring students to use single-stall unisex restrooms or restrooms associated with their physical sex.

The appellate court reversed a District Court’s dismissal of a Title IX claim by the student and said he could proceed with his lawsuit, which contends that the school board’s decision was discriminatory.

“Today’s decision gives me hope that my fight will help other kids avoid discriminatory treatment at school,” Grimm said in a statement, calling the ruling a relief and vindication.

President Barack Obama’s administration filed a brief in support of Grimm. In its ruling, the court noted that federal education officials have interpreted Title IX to extend to transgender students.

The appeals court said in its ruling that the district court “did not accord proper deference to the Department of Education’s regulations.”

The case was remanded to the District Court to be reheard.

The decision marked the first time a federal appeals court has found Title IX rights protect transgender students, the ACLU said in a statement. It could affect other states where similar cases have arisen.

The superintendent of Gloucester County Public Schools, Walter Clemons, declined to comment.

“The Fourth Circuit decision is truly unprecedented,” said Matt Sharp of the nonprofit Alliance Defending Freedom, which advocates for conservative positions on religious liberty.

“Schools are going to be told that you have to allow biological males to share bathrooms and locker rooms and other private facilities with females,” he said in a phone interview.

The ruling comes as North Carolina and Mississippi recently adopted laws seen as discriminatory to lesbian, gay, bisexual and transgender interests.

The Republican governor of North Carolina, Pat McCrory, supported the school district in the Virginia case. He said he would review the ruling.

“This is a major, major change in social norms,” he said.

North Carolina business leaders on Tuesday called for a repeal of their state’s new law, which they blamed for mounting economic losses as opponents cancel jobs and events over concerns that it discriminates against gay and transgender people.

Also Tuesday, Target Corp. said that transgender employees and customers could use the bathroom that corresponds with their gender identity, becoming the first big retailer to weigh in on the issue.

“In our stores, we demonstrate our commitment to an inclusive experience in many ways,” Target, which has 49 stores in North Carolina, said in a statement on its website. “Most relevant for the conversations currently under way, we welcome transgender team members and guests to use the restroom or fitting room facility that corresponds with their gender identity.”

Target spokeswoman Molly Snyder said the retailer had already adopted an inclusive stance toward transgender people, but that given the questions it had received on the issue, “we felt it was important to state our position.”

In 2014, the Maine Supreme Judicial Court ruled in favor of Nicole Maines in a similar lawsuit against the Orono school district, guaranteeing transgender students the right to use school bathrooms corresponding to the gender with which they identify.

In 2005, Maine voters upheld a law prohibiting discrimination in housing, education and other areas based on sexual orientation and gender identity, and it’s one of 13 states banning discrimination against students on both bases, according to the Gay, Lesbian and Straight Education Network.

Legislation focused on transgender bathroom access, as well the rights of those with religious objections, has drawn protests in several other states, mostly in the South.