It was clear, the state said, that Coy had completely integrated into society as a girl — wearing girls’ clothing, standing in the girls’ line at school and choosing to play with girls.

But the state’s ruling went even further, saying that evolving research on transgender development showed that “compartmentalizing a child as a boy or a girl solely based on their visible anatomy, is a simplistic approach to a difficult and complex issue.”

Depriving Coy of the acceptance that students need to succeed in school, Mr. Chavez wrote, “creates a barrier where none should exist, and entirely disregards the charging party’s gender identity.”

Michael D. Silverman, the executive director of the Transgender Legal Defense and Education Fund, which filed the complaint on the Mathises’ behalf, hailed the decision as a momentous victory and hoped it would sway how other school districts treated transgender students.

According to the group, 17 states and the District of Columbia offer some form of legal protections for transgender people. And the issue of how schools treat transgender students has grown especially prominent in recent years.

“This is the first ruling in the nation that holds that transgender students be allowed to use bathrooms that match who they are,” he said. “There are thousands of families like the Mathises who are feeling relieved and vindicated that the commission ruled that Coy is a girl just like any other girl.”

A lawyer for the school district did not respond to requests for comment. The school district had argued it acted reasonably in the dispute, saying Coy was permitted to wear girls’ clothing to school and was referred to as female.