It's been a tough year for proponents of gay-conversion therapy: In 2015, 18 state legislatures considered or enacted laws against ex-gay therapy for minors, a program promising to turn gay men straight was deemed a fraud by a New Jersey civil court, and even President Obama condemned the practice.

So it's fitting that, in its twilight, the ex-gay movement is now the subject of a new history, by Temple University sociologist Tom Waidzunas.

The Straight Line: How the Fringe Science of Ex-Gay Therapy Reoriented Sexuality, released by the University of Minnesota Press, documents the evolution and decline of "reorientation" - which began with early experiments like induced seizures, electroshock, and aversion therapy, and continued in the mainstream psychology community well into the 2000s.

Waidzunas tells the story of how gay activists won the debate over whether homosexuality was a curable condition - and of the unpredictable consequences of that victory.

In 2013, New Jersey banned conversion therapy for minors. Pennsylvania State Rep. Brian Sims and State Sen. Anthony Williams, Philadelphia Democrats, have proposed such a ban in the commonwealth.

But, Waidzunas said, "the worry is, the more we make these ex-gay therapies illegal, the more they go underground."

When Waidzunas began his book, the debate was still raging in the medical community, among religious leaders, and in the media.

He began attending conferences - of the National Association for Research and Therapy of Homosexuality (NARTH), founded in 1992 by reorientation therapists who felt marginalized by mainstream psychiatric organizations; of Exodus International, the now-defunct Christian ex-gay organization; and of the American Psychological Association, which didn't formally renounce reorientation therapies as ineffective until 2009.

"I got insight into the worldview of how these folks understand that they can change people's sexual orientation by addressing what they claim is their underlying gender wounding," Waidzunas said. "Going to the NARTH conference, I got a sense of how this movement saw itself as being under siege."

Meanwhile, more ex-gays came out publicly as ex-ex-gays - including the president of Exodus International, Alan Chambers, who in shutting down the organization in 2013 conceded that he still felt same-sex attraction.

In the end, Waidzunas noted, religious groups and the psychology community ended up more or less on common ground.

"The American Psychological Association took an intermediary position . . . where if a person's sexual feelings were incongruent with their religious values and their religion was so important to them personally, it might be that they should pursue a heterosexual identity."

Today, calls for suppressing homosexual urges, even if that means lifelong abstinence, also are part of what's sometimes called Side B Christianity.

Harvest USA, an organization based in Philadelphia, counsels ministries around the country on how to "care for sexually hurting people."

John Freeman, president of the group, declined an interview request. The goal for gay Catholics is still abstinence, according to Courage International.

The Archdiocese of Philadelphia runs a chapter that meets biweekly, attracting 10 members on a good day, said the Rev. Philip Bochanski, who was chaplain of the local group until earlier this year, when he became associate director of Courage International.

"It's about mutual encouragement and support," he said. "Courage is about helping a person to live a chaste life. We're not setting out to change anybody's orientation."

The organization is now at work in Asia, Europe, and Australia. Bochanski said he had made preliminary contacts in September with pilgrims from African countries during the World Meeting of Families.

Waidzunas noted that kind of outreach could be complicated.

In the United States, he said, reorientation therapists have lost the debate.

But in doing research overseas, he saw the dangerous consequences of bringing to developing countries those arguments about whether sexual orientation could be changed.

"When that idea is exported to other countries that have a lot more fluidity of sexual expression, it can create a backlash," he said. "If you have a culture where men can hold hands walking down the street, and then you import these notions of gay and straight sexuality, it disrupts that."

In the course of his research, he spent time in Uganda, where in recent years, gay people have faced persecution and physical violence; hundreds have fled the country. Last year, legislators made homosexual acts punishable by lengthy prison sentences. Uganda's constitutional court overturned the law, but the antigay climate there remains.

"I met these young people who were hoping to get married and were escaping really oppressive conditions," said Waidzunas. "The gravity of what I was working on became so much stronger."