School officials violated state anti-discrimination law when they prevented a transgender fifth-grader from using the girls' bathroom, according to a ruling by the highest court in Maine believed to be the first of its kind.

The family of student Nicole Maines and the Maine Human Rights Commission sued in 2009 after school officials required her to use a staff restroom.

"This is a momentous decision that marks a huge breakthrough for transgender young people," said Jennifer Levi, director of the Boston-based Gay & Lesbian Advocates & Defenders' Transgender Rights Project (Glad) after the Maine supreme judicial court's ruling on Thursday.

The court concluded that the Orono school district's actions violated the Maine Human Rights Act, which bans discrimination based on sexual orientation or gender identity, overturning a lower court's ruling that the district acted within its discretion.

The ruling is the first time a state high court concluded that a transgender person should use the bathroom of the gender with which they identify, according to Glad. Federal courts have not taken up the issue.

Students at the southern Maine high school attended by Nicole stood up and cheered when news of the ruling was announced, said her father, Wayne Maines.

School administrators across the country are grappling with the issue.

Colorado officials said last year that a suburban Colorado Springs school district discriminated against a six-year-old transgender girl by preventing her from using the girls' bathroom.

In California, efforts are continuing to try to repeal a law that allows public school students to use bathrooms and locker rooms that correspond with their expressed genders.

In the Maine case, Nicole Maines was using the girls' bathroom in her elementary school until the grandfather of a fifth-grade boy complained to administrators. The Orono school district determined that she should use a staff bathroom, but her parents said that amounted to discrimination.

Nicole is a biological male who identified as a girl from the age of two.

Nicole, now 16, said after arguments before the high court last summer that she hoped the justices understood the importance of going to school, getting an education and making friends without having to be "bullied" by other students — or school administrators.

Nicole's father said all he had ever wanted was for his daughter to be treated like her classmates. He said he was overcome with emotion when he learned of the court's decision.

"It sends a message to my kids that you can believe in the system and that it can work," Wayne Maines said. "I'm just going to hug my kids and enjoy the moment, and do some healing."

Melissa Hewey, lawyer for the school district, said the ruling provided clarity not just to Orono, but to schools around the state.

"The court has now clarified what has been a difficult issue and is a more and more common in schools, and the Orono school department is going to do what it needs to do to comply with the law," she said.

In the five-to-one ruling, the court had to reconcile two separate state laws, one requiring separate bathrooms based on gender and the other prohibiting discrimination based on sexual orientation.

In this case, in which the child had a formal diagnosis of gender dysphoria, "it has been clearly established that a student's psychological wellbeing and educational success depend upon being permitted to use the communal bathroom consistent with her gender identity," Justice Warren Silver wrote.

The supreme judicial court pointed out that its ruling was based on the circumstances of the case in which there was ample documentation of the student's gender identity. "Our opinion must not be read to require schools to permit students casual access to any bathroom of their choice," he wrote.