SACRAMENTO—The U.S. Court of Appeals for the Ninth Circuit on Tuesday upheld a California law banning psychotherapy aimed at changing gay minors’ sexual orientation.

The unanimous three-judge panel held that the four-year-old law does not violate either the First Amendment’s free exercise and establishment clauses or the privacy rights of minors. The law does not improperly restrict the activities of clergy who offer religious guidance to their congregants, the court said.