U.S. District Judge Kimberly Mueller said the state Legislature and Gov. Jerry Brown had enough grounds to enact such a law, set to take effect Jan. 1, given that multiple mental health groups, including the American Psychological Association, had discredited the therapy.
Her ruling Tuesday came a day after U.S. District Judge William Shubb, also in Sacramento, ruled in a separate case raising the same issue that the law might infringe on First Amendment rights of therapists who oppose homosexuality.
He issued a temporary restraining order preventing the state from enforcing the ban, the first of its kind in the nation, against the three plaintiffs pending a broader ruling on its merits.
He said the scientific evidence challenging the practice was "incomplete."
The office of state Attorney General Kamala Harris said the ban would take effect as scheduled for everyone except two therapists and an aspiring therapist who sued to keep the ban from taking effect.
"The reality is those three individuals are not subject to the law, so [the initial ruling] is very narrow," spokeswoman Lynda Gledhill told the Los Angeles Times.
Democratic State Sen. Ted Lieu, who wrote the law, said in a statement, "On behalf of the untold number of children who can expect to be spared the psychological abuse imposed by reparative therapy, I'm thrilled that today's ruling by Judge Mueller will continue to protect our children from serious harm."
So-called conversion therapy, also known as "reparative therapy," has been a source of intense controversy in the United States and other countries.
Four homosexual men who underwent the therapy filed a civil lawsuit against a New Jersey counseling group under the state's Consumer Fraud Act last month, saying they were deceived.
CNN said the techniques described in that lawsuit included having participants strip naked in group sessions, cuddle people of the same sex, violently beat an effigy of their mothers with a tennis racket, visit bath houses "to be nude with father figures" and be "subjected to ridicule as 'faggots' and 'homos' in mock locker room scenarios."
Scarlett Johansson steps out with fiance after pregnancy reveal
Jessica Simpson shares three-way kiss with friends in photo