The Maine Supreme Judicial Court on Thursday ruled that denying a transgender girl the use of the girls bathroom at her school violated her rights under Maine's Human Rights Act, which prohibits discrimination based on gender identity.

In a 5-1 decision, the justices reversed a lower court's ruling that sided with Orono school district, now called Riverside RSU 26.

“Our opinion must not be read to require schools to permit students casual access to any bathroom of their choice,” writing for the majority, Justice Warren Silver said. “Decisions about how to address students' legitimate gender identity issues are not to be taken lightly. Where, as here, it has been clearly established that a student's psychological well-being and educational success depend upon being permitted to use the communal bathroom consistent with her gender identity, denying access to the appropriate bathroom constitutes sexual orientation discrimination in violation of the [Maine Human Rights Commission].”

Parents of the girl, Nicole Maines, now 15, filed their lawsuit in 2007 after their daughter was told she could no longer use the girls bathroom at the Asa Adams Elementary School in Orono and was instructed to use a staff bathroom instead. Administrators acted after the grandfather of a male student complained.

Gay & Lesbian Advocate & Defenders (GLAD), the Boston-based legal group devoted to LGBT cases, represented the Maines family.

“This is a momentous decision that marks a huge breakthrough for transgender young people,” said Jennifer Levi, director of GLAD's Transgender Rights Project, who argued the case. “Schools have a responsibility to create a learning environment that meets and balances the needs of all kids and allows every student to succeed. For transgender students this includes access to all school facilities, programs and extracurricular activities in a way that is consistent with their gender identity.”

After oral arguments in June, Nicole Maines told reporters: “I wouldn't wish my experience on another trans person. … I am happy the court was able to hear my case today.”

Wayne Maines, Nicole's father, on Thursday said that he was happy to “close this very difficult chapter in our lives.”

“As parents all we've ever wanted is for Nicole and her brother Jonas to get a good education and to be treated just like their classmates, and that didn't happen for Nicole,” Mr. Maines said. “We are very happy knowing that because of this ruling, no other transgender child in Maine will have to endure what Nicole experienced.”