A federal appeals court ruled Tuesday that a transgender Wisconsin high school senior who identifies as male can use the boys' bathroom.

The ruling, a victory for Ashton Whitaker, 17, of George Nelson Tremper High School in Kenosha, came the same week that he graduates. Nonetheless, he said he was thrilled with the decision.

"I hope my case will help other transgender students in Kenosha and elsewhere to just be treated the same as everyone else without facing discrimination and harassment from school administrators," he said.

Ashton Whitaker, right, hugs his mother, Melissa, in Kenosha, Wisconsin, in an undated photo provided by the Transgender Law Center. Transgender Law Center / AP

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

A three-judge panel of the 7th U.S. Circuit Court of Appeals ruled unanimously that the Kenosha Unified School District violated a federal law and Ashton's constitutional rights by insisting that he use either the girls' bathroom or a separate gender-neutral restroom in the school's main office.

The court dismissed as "sheer conjecture and abstraction" the school district's argument that its refusal to let him use the boys' bathroom was based on a need to protect student privacy.

"For nearly six months, Ash used the boys' bathroom while at school and school-sponsored events without incident or complaint from another student," the court said. "It was only when a teacher witnessed Ash washing his hands in the restroom that his bathroom usage once more became an issue in the school district's eyes."

The court said a transgender student's presence in the bathroom provides no more of a risk to the privacy of other students "than the presence of an overly curious student of the same biological sex who decides to sneak glances at his or her classmates."

Another appeals court had ruled that schools must allow students to use the restrooms matching their gender identities. But that ruling, from the 4th Circuit involving a Virginia student, was vacated by the Supreme Court after the Trump administration canceled the Obama administration's legal guidance on transgender bathroom protections in public schools.

However, four other appeals courts have ruled, outside of the school context, that transgender people can prevail on claims of sex discrimination.

Ashton's lawyer, Ilona Turner of the Transgender Law Center, said the ruling "is just another building block on the large and growing number of courts to hold that discrimination against transgender people is illegal."

Ashton told his parents in the eighth grade that he identified as a boy. He legally changed his name and began hormone replacement therapy.

Tuesday's ruling said the school district violated a federal law, Title IX, that prohibits schools from discriminating on the basis of sex. Previous federal court rulings have said that gender stereotyping is a form of sex discrimination.

"By definition, a transgender individual does not conform to the sex-based stereotypes of the sex that he or she was assigned at birth," the appeals court said.