First it was Republicans, and now Democrats, scrambling in recent presidential elections to snuggle up closely to men of the cloth, seeking the endorsement of well-known clergymen and campaigning with preachers, all in an effort to demonstrate how godly they are.

But a curious thing has happened in this year's contest for the White House. Candidates are having to distance themselves from preachers, almost as quickly as they had sought their embrace. Sen. Barack Obama (D-Ill.) denounced his former pastor, the Rev. Jeremiah A. Wright Jr., who was videotaped asserting that the federal government had brought the AIDS virus into black communities and that God should "damn" America.

Sen. John McCain (R-Ariz.) has found it necessary to disassociate himself from the Rev. John Hagee and the Rev. Rod Parsley, two conservative preachers who have expressed, respectively, anti-Catholic and anti-Muslim views. Just last week, Obama and his wife resigned from their church after a guest minister, the Rev. Michael L. Pfleger, mocked Sen. Hillary Rodham Clinton (D-N.Y.).

Clergy have become ticking time bombs in this year's presidential campaign, so much so that the Obamas say they won't join another place of worship until after the election -- if then.

The recent spate of embarrassing episodes has prompted soul-searching about the role of religion in politics. Surprisingly, it has come both from those who complain about the intersection of political and religious issues, and those who want a strong faith presence in public life.

"Look, remove religion from politics and the abolition of slavery and the civil rights movement would never have happened. The religious element has always been there," said Charles Dunn, dean of the Robertson School of Government at Regent University, a Christian school in Virginia Beach. "I don't oppose debates about the role of religion in politics but I oppose the current excesses of the debate."

Concern is high among many evangelicals, the group seen as drivers, beneficiaries as well as victims of the current climate. Dozens of prominent evangelicals last month signed what they titled a "manifesto," bemoaning the politicization of faith, which is "never a sign of strength but of weakness." It said evangelicals have a duty not to be equated with a political party, partisan ideology or nationality.

With some of the most explosive religion-related incidents this year involving a Democrat, many voters and professional observers have noted the party's concerted effort since 2004 to reach out to faith voters -- and point to a link.

"The chickens are coming home to roost," said Jacques Berlinerblau, a Georgetown University sociologist who writes a religion and politics blog called "The God Vote." A post that got 50,000 hits called "Huckobama" asked why Democrats who have criticized President Bush's overt faith expressions aren't more critical of Obama.

"That's the new Faith-and-Values friendly liberalism of the Democratic Party in 2008. And that's something that might make it hard for secularists to live their lives in peace," he wrote.

Among the speeches Berlinerblau cited was one Obama made in February, preaching at length about Jeremiah 29, saying, "God has a plan for his people." The separationist group Interfaith Alliance has been sending out alerts about candidates for months, including when Clinton said last June that she'd like to "inject" faith into policy and when McCain said in September that the Constitution established "a Christian nation." The group also included an Obama speech in October in which he told an audience that, with prayer and praise, "I am confident that we can create a kingdom right here on Earth."

Democratic strategists have lamented off the record such comments, and the pamphlet Obama has used in at least two states, titled "Committed Christian." Others say the problem isn't faith in politics but a gloves-off campaign culture.

"I don't think anyone wants people's pastors parsed, but to me I don't think that has to do with religion, but with attack politics, where everything is fair game," said Democratic pollster Mark Mellman. Mellman said the discussion of faith in campaigns must continue because religion is such an important part of many Americans' identities.

The Rev. John Thomas, president of the United Church of Christ, Obama's denomination, issued a statement this week agonizing over the Obamas' decision to leave Trinity United Church of Christ in Chicago. "Many candidates and public officials now find it nearly impossible to be an active member of a particular religious community, given our divisive political culture."

The Rev. Welton Gaddy, the Monroe, La., Baptist minister who heads the Interfaith Alliance, also issued a statement of regret about the Obamas' decision. "This is a sad day in American politics and even sadder in American religion. Senator Obama is at the center of the storm, but all who wed religion to partisan politics share responsibility for this tragic development.''

Many voters say they don't like the religion-politics blend, for varying reasons.

Anna Torres, 30, an evangelical Democrat and stay-at-home mother from Los Angeles, said the stream of controversies shows that "religion tends to hurt the nominee. They should be more focused on talking about how they'll run the country and not religion. Those two need to be separated."

Joel Hammons, a 51-year-old coal miner from Craigsville, W. Va., said he is a Christian leaning toward voting for McCain. He said there hasn't been enough of the ''right'' kind of talk in the campaign about religion, about what he calls "moral" issues such as abortion and capital punishment. But there has been, he said, too much of the ''wrong'' kind of talk, in which pastors like Hagee and Wright are cited by candidates and then tossed overboard.

"These candidates, as long as they can use somebody to gain votes, they'll stick right with them. But when the going gets rough, they want to bail out. It makes them look worse than if they hadn't even affiliated to begin with," Hammons said.

Susan Jacoby, who writes about American religion and secularism, sees problems coming from several corners. Candidates are "getting what they deserve," she said, by talking so much about their faith beliefs. But the blame rests on the public, she said, for maintaining superficial attitudes to something as complex as faith.

"Pastors who say nutty things goes against our myth about churches, which is that only good and nice things are said in them," she said. "Americans don't want to look into the messy side of religion. They want candidates to be religious, but they want that faith to be a very bland, ecumenical, acceptable-to-all kind of faith. That's like asking for the moon."