Mr. Smith, 58, who says he believes homosexual behavior is wrong on religious grounds, tried to tough it out. He spent 17 years in a doomed marriage while battling his urges all day, he said, and dreaming about them all night.

But in recent years, as he probed his childhood in counseling and at men’s weekend retreats with names like People Can Change and Journey Into Manhood, “my homosexual feelings have nearly vanished,” Mr. Smith said in an interview at the house in Bakersfield, Calif., he shares with his second wife, who married him eight years ago knowing his history. “In my 50s, for the first time, I can look at a woman and say ‘she’s really hot.’ ”

Mr. Smith is one of thousands of men across the country, often known as “ex-gay,” who believe they have changed their most basic sexual desires through some combination of therapy and prayer — something most scientists say has never been proved possible and is likely an illusion.

Ex-gay men are often closeted, fearing ridicule from gay advocates who accuse them of self-deception and, at the same time, fearing rejection by their church communities as tainted oddities. Here in California, their sense of siege grew more intense in September when Gov. Jerry Brown signed a law banning use of widely discredited sexual “conversion therapies” for minors — an assault on their own validity, some ex-gay men feel.

Signing the measure, Governor Brown repeated the view of the psychiatric establishment and medical groups, saying, “This bill bans nonscientific ‘therapies’ that have driven young people to depression and suicide,” adding that the practices “will now be relegated to the dustbin of quackery.”

But many ex-gays have continued to seek help from such therapists and men’s retreats, saying their own experience is proof enough that the treatment can work.

Aaron Bitzer, 35, was so angered by the California ban, which will take effect on Jan. 1, that he went public and became a plaintiff in a lawsuit challenging the law as unconstitutional.

Photo

“In my 50s, for the first time, I can look at a woman and say, ‘She’s really hot.’ ” - BLAKE SMITH, a veteran of counseling and men’s retreatsCredit
Monica Almeida/The New York Times

To those who call the therapy dangerous, Mr. Bitzer reverses the argument: “If I’d known about these therapies as a teen I could have avoided a lot of depression, self-hatred and suicidal thoughts,” he said at his apartment in Los Angeles. He was tormented as a Christian teenager by his homosexual attractions, but now, after men’s retreats and an online course of reparative therapy, he says he feels glimmers of attraction for women and is thinking about dating.

“I found that I couldn’t just say ‘I’m gay’ and live that way,” said Mr. Bitzer, who plans to seek a doctorate in psychology and become a therapist himself.

Many ex-gays guard their secret but quietly meet in support groups around the country, sharing ideas on how to avoid temptations or, perhaps, broach their past with a female date. Some are trying to save heterosexual marriages. Some, like Mr. Bitzer, hope one day to marry a woman. Some choose celibacy as an improvement over what they regard as a sinful gay life.

Whether they have gone through formal reparative therapy, most ex-gays agree with its tenets, even as they are rejected by mainstream scientists. The theories, which have also been adopted by conservative religious opponents of gay marriage, hold that male homosexuality emerges from family dynamics — often a distant father and an overbearing mother — or from early sexual abuse. Confronting these psychic wounds, they assert, can bring change in sexual desire, if not necessarily a total “cure.”

(While some women also struggle with sexual identity, the ex-gay movement is virtually all male.)

Major mental health associations say teenagers who are pushed into therapy by conservative parents may feel guilt and despair when their inner impulses do not change.

Reparative therapy suffered two other major setbacks this year. In April, a prominent psychiatrist, Dr. Robert L. Spitzer, publicly repudiated as invalid his own 2001 study suggesting that some people could change their sexual orientation; the study had been widely cited by defenders of the therapy.

Then this summer, the ex-gay world was convulsed when Alan Chambers, the president of Exodus International, the largest Christian ministry for people fighting same-sex attraction, said he did not believe anyone could be rid of homosexual desires.

Joseph Nicolosi, a psychologist and clinical director of the Thomas Aquinas Psychological Clinic in Encino, Calif., which he describes as the largest reparative therapy clinic in the world, disagreed.

“I don’t believe that anybody is really gay,” he said. “I believe that all people are heterosexual but that some have a homosexual problem, and some of these people attempt to resolve their conflict by adopting a sociopolitical label called ‘gay.’ ”

Photo

“If I’d known about these therapies as a teen I could have avoided a lot of depression, self-hatred and suicidal thoughts.” - AARON BITZER, plaintiff in a lawsuit challenging a California lawCredit
Monica Almeida/The New York Times

Jeremy S., 34, a corporate contract officer in Dallas, says he is among them. Jeremy, who did not want his last name printed to avoid embarrassing his parents, said that from his teens until three years ago he lived as a gay man, at times having sex almost daily. “It wasn’t working for me,” he said.

After two years of therapy via Skype with Dr. Nicolosi’s clinic, he said, “my attraction to men was drastically diminishing.” He said he has not had sex with a man for more than two years and does not think about it more than once a month, adding that his Catholic faith has also deepened.

Critics like Wayne Besen, the executive director of Truth Wins Out, which fights antigay bias, liken such therapy to faith healing, with apparent effects that later fade away.

They also point out that the failures of such therapy are seldom reported.

S. Marc Breedlove, a neuroscientist and psychologist at Michigan State University, said there was overwhelming evidence that sexual orientation is affected by both biology and environment. Clearly, he said, reparative therapy helps some people alter sexual behavior. But that is far different, he noted, from transforming instinctive sexual desires, something never proved in scientific studies.

Cameron Michael Swaim, 20, said he is in the early stages of his struggle to overcome homosexual desires. Mr. Swaim is unemployed and lives with his parents in Orange County, Calif., where his father is a pastor of the Evangelical Friends Church of the Southwest.

He tried the gay life, but “it just doesn’t settle with me,” he said, and ultimately decided “there’s got to be a way to heal this affliction.”

Through weekend retreats and participation in a Southern California support group Mr. Swaim has started to explore his family relations, he said, something that has been painful but seems to be helping.

“I’m building my confidence around men,” he said, “ and that has built my confidence around women.”

Five years from now, Mr. Swaim hopes, he will be engaged or married. In the meantime, he is trying to scrape together enough money to start seeing a reparative therapist.

A version of this article appears in print on November 1, 2012, on page A16 of the New York edition with the headline: ‘Ex-Gay’ Men Fight Back Against View That Homosexuality Can’t Be Changed. Order Reprints|Today's Paper|Subscribe