A Virginia school board defended its transgender bathroom ban before a federal appeals court Tuesday, as a transgender man who was barred as a student from using the boys' bathrooms at his high school argued that the policy discriminated against him and violated his constitutional rights.

A judge ruled last year that the Gloucester County School Board had discriminated against Gavin Grimm, but the board appealed that ruling to the 4th U.S. Circuit Court of Appeals in Richmond.

David Corrigan, a lawyer for the school board, said school officials treated Grimm with respect after he began transitioning from female to male during high school, accommodating his request to use male pronouns and to be called by his new name.

Grimm had chest reconstruction surgery and hormone therapy. He also obtained a Virginia court order and Virginia birth certificate declaring his sex is male in 2016, when he was in 12th grade.

Grimm's lawsuit alleged that the school board violated Grimm's equal protection rights as well as Title IX, the federal policy that protects against gender-based discrimination.

But Corrigan argued that the law protects against discrimination based on gender, not gender identity. Corrigan said that because Grimm had not undergone sex-reassignment surgery and still had female genitalia, the board’s position was that he remained anatomically a female.

“Our position is it’s a binary concept, that you have males and females,” Corrigan said.

Joshua Block, an attorney with the American Civil Liberties Union, said the board treated Grimm differently than other students when it required him to use separate but unequal facilities — either bathrooms that corresponded with his biological gender — female — or private bathrooms.

“They were stigmatizing and humiliating,” Block said.

“It’s stigmatizing to be excluded from the facilities that everyone else uses," he said.

Grimm’s lawsuit was once a federal test case that drew national attention. He graduated in 2017 from Gloucester High School, located in a mostly rural area about 60 miles (95 kilometers) east of Richmond.

The three-judge panel that heard the case Tuesday did not indicate when it would issue a ruling. The arguments were held remotely because of the coronavirus pandemic.

The hearing was the latest step in a years-long legal battle. Grimm’s lawsuit was supposed to be heard by the U.S. Supreme Court. But the high court hearing was canceled after President Donald Trump rescinded an Obama-era directive that students can choose bathrooms corresponding with their gender identity.

U.S. District Judge Arenda Wright Allen in Norfolk ruled in August that the board discriminated against Grimm.

”(T)here is no question that the Board’s policy discriminates against transgender students on the basis of their gender noncomformity,” Allen wrote.

“Under the policy, all students except for transgender students may use restrooms corresponding with their gender identity,” she continued. “Transgender students are singled out, subjected to discriminatory treatment, and excluded from spaces where similarly situated students are permitted to go.”