The United States Court of Appeals for the Ninth Circuit on Thursday upheld a California law prohibiting licensed therapists from attempting to change the sexual orientation or gender expression of anyone under 18 years old.

"California has authority to prohibit licensed mental health providers from administering therapies that the legislature has deemed harmful, and the fact that speech may be used to carry out those therapies does not turn the prohibitions of conduct into prohibitions of speech," Circuit Judge Susan Graber wrote in the ruling. "The panel further concluded that the First Amendment does not prevent a state from regulating treatment even when that treatment is performed through speech alone."

The Liberty Counsel filed a federal lawsuit last year challenging California's ban on a practice known as "reparative," "conversion," or "ex-gay" therapy. The conservative legal group alleged that the law violated constitutional guarantees of freedom of speech and prevented patients from being provided the full range of treatment options.

"Legislators and judges in the state of California have essentially barged into the private therapy rooms of victimized young people and told them that their confusion, caused by the likes of a Jerry Sandusky abuser, is normal and they should pursue their unwanted and dangerous same-sex sexual attractions and behavior, regardless of whether those minors desire their religious beliefs to trump their unwanted attractions," Mat Staver, founder and chairman of Liberty Counsel, said in a statement.

LGBT rights groups have described reparative therapy as a dangerous and discredited practice.

"This decision clears the way for this life-saving law to protect California youth from cruel and damaging practices that have been rejected by all leading medical and mental health professional organizations," Shannon Minter of the National Center for Lesbian Rights, who argued the case on behalf of Equality California, said.

"The court of appeals ruled in very clear terms that state-licensed therapists do not have a constitutional right to engage in discredited practices that offer no health benefits and put LGBT youth at risk of severe harm, including depression and suicide."

Under California's law, those older than 18 can still receive reparative therapy from licensed therapists.