“The idea of using the girls restroom was humiliating and there was no way I could do it,” he said in a court document filed in August 2016. “If I were to use the gender-neutral restrooms, I would also stand out from everyone else with a big label on me that said ‘transgender.’”

He described feeling “scrutinized and degraded” when administrators repeatedly tried to keep him out of the boys restrooms, or when they used female pronouns after he had asked them not to. He added that he suffered from anxiety, depression, migraines and other health problems related to dehydration because he had tried to avoid restroom trips by drinking less water.

A Federal District Court judge granted an injunction that allowed Mr. Whitaker to use boys bathrooms during his senior year. The school district appealed that decision to the Seventh Circuit Court of Appeals. The district’s lawyers argued in part that “a student cannot unilaterally declare their gender then demand that they be treated like ‘all others’ in that sex classification.”

But the appeals court judges upheld the injunction in May 2017.

The school district then filed a petition to appeal that ruling to the United States Supreme Court. But on Tuesday, the school board voted 5 to 2 to pay an $800,000 settlement to Mr. Whitaker instead and to withdraw its petition, according to The Kenosha News.

Mr. Whitaker, in a statement emailed by the Transgender Law Center, which represented him, said he was “deeply relieved” that the court case was over and he could focus on being a college student. “Winning this case was so empowering and made me feel like I can actually do something to help other trans youth live authentically,” he said.