California Governor Jerry Brown has signed into law a ban on therapy aimed at making gay teenagers straight.
When the law comes into effect on 1 January, the Golden State will become the first to outlaw the practice for people under the age of 18.
The bill was backed by mental health groups, and gay rights activists say reparative or "conversion therapy" can increase risk of depression or suicide.
Counselling and prayer is used to help some Christians deal with gay urges.
The bill was signed over the weekend along with more than 100 pieces of legislation sent to the governor by California's state legislature.
Two Christian groups, the California-based Pacific Justice Institute and the Florida-based Liberty Counsel will challenge the law.
The Liberty Counsel said it planned to argue in its lawsuit that the measure infringes on the First Amendment and equal protection rights.
In his statement, Gov Brown said sexual orientation change efforts "have no basis in science or medicine and they will now be relegated to the dustbin of quackery".
The Human Rights Campaign, an advocacy group, said: "We're grateful to Governor Brown for standing with California's children.
"LGBT [lesbian, gay, bisexual and transgender] youth will now be protected from a practice that has not only been debunked as junk science, but has been proven to have drastically negative effects on their well-being," the gay rights advocate added, urging other states to take up similar measures.
But the National Association for Research and Therapy on Homosexuality said the bill was a "legislative over-reach".
Some conservative groups have said banning the therapy would restrict a parent's right to care for children going through gender confusion.
California is embroiled in a long-standing legal tussle over gay marriage.
A law called Proposition 8 banned same-sex marriage in California just months after it had been introduced. But a court overturned the ban in 2010.
After an appeal was upheld, the matter may now come before the US Supreme Court for a final ruling.