The Arizona Supreme Court ruled that a court can order parents to provide counseling and other treatment for transgender kids, even if one parent isn’t supportive. The court also ruled that a family court had overstepped in ordering parents to treat their transgender daughter like a boy.

The ruling said that courts can intervene if the child is “at risk for physical danger or significantly impaired emotionally,” a higher legal standard than “the best interests of the child.”

The case that led to the ruling involved a divorced heterosexual couple – identified as Paul E. and Courtney F. in court documents – who have three children together. After their divorce, they got joint legal decision-making authority and equal time with their kids, with Paul getting final authority over their children’s medical and educational decisions.

One of their children, L., made is known at around age 5 that she identifies as a girl. Her mother supported her and let her wear female clothing to school without telling her father.

Related: Don Cheadle showed his support for transgender kids, and Twitter went wild

Paul got mad and asked a court to intervene, saying that Courtney was pushing a transgender identity on their daughter. A family court agreed and ordered Courtney to refer to L. with male pronouns, to remove any “girl-oriented toys” from her house, to dress L. in boys’ clothes, and to avoid discussing gender issues with her daughter.

As the parents’ legal battles continued, the rules about treating L. as if she were a boy remained in place for several years. In the mean time, she was diagnosed with gender dysphoria by multiple mental health professionals and grew resentful of her father, who she blamed for putting the gender-based rules in place.

During that time, Paul kept a log of his daughter’s gender expression and even in 2015 said that her gender dysphoria was “in remission,” “a position at odds with the experts,” according to the state supreme court’s ruling.

The father asked for sole decision-making authority and was awarded it, but the family court also required him to continue providing L. with therapy with a certain therapist. He appealed the decision and an appeals court agreed with him, saying that a family court can’t choose a therapist.

The appeals court also found that the family court didn’t have the authority to impose parenting choices like not discussing gender with L.

The mother appealed to the state supreme court, saying that the therapy is needed to protect L.’s mental and physical health. The court just ruled that the family court could impose therapy and a certain therapist.

“The evidence supports findings implicit in the court’s orders, however, that L. would be physically endangered or suffer significant emotional impairment if Father fails to maintain therapy for L.or retain a gender expert or if he declines to allow L. to gender explore,” the ruling states.

“When an impasse occurs, the court is authorized to determine not only the parenting plan element in dispute, but also ‘other factors that are necessary to promote and protect the emotional and physical health of the child.”

Miami University professor of family science Katherine Kuvalanka said that the ruling is a “win.” She is a researcher who focuses on custody fights and transgender children.

Studies have “consistently shown that acceptance and support is imperative for this population, and that a lack of acceptance and rejection often has tragic results,” she told AZ Central.