The law prohibiting "sexual orientation change efforts" for minors, abbreviated as SOCE and sometimes known as gay conversion therapy, was enacted last year and was the first of its kind in the nation.
Since then, New Jersey has adopted a similar law.
A three-judge panel of the 9th U.S. Circuit Court of Appeals unanimously rejected arguments in which several therapists, parents and patients claimed the California law violated the constitutional right of free speech.
Circuit Judge Susan Graber wrote that the measure regulates conduct, not speech.
"It bans a form of medical treatment for minors; it does nothing to prevent licensed therapists from discussing the pros and cons of sexual orientation change therapy with their patients," Graber wrote.
The law applies to state-licensed mental health providers.
It was challenged in two separate lawsuits filed in federal court in Sacramento. In one case, a trial judge issued a preliminary injunction blocking enforcement of the law; in the other case, a different judge declined to do so.
Today's ruling orders that injunction lifted, unless the groups challenging the law are able to win a stay from an expanded appeals court panel or the U.S. Supreme Court.
The three-judge panel also said the Legislature had a rational basis for enacting the law after considering reports in which the American Psychological Association and other professional groups concluded that conversion therapy could harm children.
"Without a doubt, protecting the well-being of minors is a legitimate state interest," Graber said in the court opinion.
She wrote that in the reports cited by the Legislature, "the overwhelming consensus was that SOCE was harmful and ineffective."