Chris Carlson, Associated Press
Presidential hopeful Sen. Barack Obama, D-Ill., greets people during a campaign stop in downtown Rapid City, S.D., on Saturday.

ABERDEEN, S.D. — Barack Obama has quit his church of two decades, saying Saturday that the racial and other controversies of recent months had become too great a distraction for his presidential run while his campaign brought too much unfair attention upon a congregation that he cares for deeply.

The Democratic frontrunner's decision to leave Trinity United Church of Christ in Chicago, made official Friday in a letter to its pastor, the Rev. Otis Moss Jr., comes as Obama prepares to wrap up the last primary contests on Tuesday and compete in a general election in which polls show he must build more trust with working-class whites dubious of his motives.

In a news conference after a campaign speech in Aberdeen, S.D., Obama told reporters that he and his wife, Michelle, had been considering leaving the church since the retired Rev. Jeremiah Wright's incendiary remarks at the National Press Club several weeks ago. Those followed earlier sermons in which Wright proclaimed "God damn America," suggested U.S. foreign policy and Israel helped provoke the 9/11 attacks, railed against the white establishment and criticized Obama's opponent for the Democratic presidential nomination, Sen. Hillary Clinton.

Obama distanced himself from Wright, saying those sermons went against his philosophies. He also delivered a major speech on race in America. Wright, angered by Obama's cold shoulder, accused Obama at the press club of political expediency. The controversies also have fueled false rumors that Obama is Muslim or doesn't say the Pledge of Allegiance.

Obama's announcement came less than a week after yet another controversy involving racially incendiary remarks from Obama's church's pulpit — this time from a guest pastor.

The Rev. Michael Pfleger of St. Sabina Catholic Church in Chicago had mocked Clinton for tearing up during the New Hampshire primary. Fake-sobbing, he said she and other whites assumed she would be the nominee because of their sense of white entitlement and supremacy.

"We don't want to have to answer for everything that's stated in a church," Obama said Saturday. "On the other hand, we also don't want a church subjected to the scrutiny that a presidential campaign legitimately undergoes."

He made clear, however, "I'm not denouncing the church and I'm not interested in people who want me to denounce the church." He said the church's congregation does not hold anti-white or anti-American views.

"I did not anticipate my fairly conventional Christian faith being subject to such challenge," he added.

Of his withdrawal, Obama said: "I have no idea how it will impact my presidential campaign, but I know that it's the right thing to do for the church and for our family."

The Illinois senator said he and his wife didn't expect to settle on another church until next January, after they know where they'll be living.