"It's what keeps me grounded. It's what keeps my eyes set on the greatest of heights," Obama told members of the Redemption World Outreach Center, whose 4,200-seat sanctuary was mostly full.
Faith, he said, is "what propels me to do what I do and when I am down it's what lifts me up." The Democratic presidential candidate said God "is with us and he wants us to do the right thing," including breaking down the divisions between Democrats and Republicans and among religions.
When people work together, he said, there is "nothing that can stop us because that's God's intention."
The Illinois senator is a member of the United Church of Christ, a church of about 1.2 million members that is considered one the most liberal of the mainline Protestant groups.
The service at the center, founded by an International Pentecostal Holiness Church minister, had members on their feet much of the time singing, swaying and raising their hands. Thumping, rock-concert loud music played from a pulpit sometimes awash with fog and filled with a band and choir.
Obama asked the church's members to pray for him and his family. "Sometimes this is a tough role, being in politics. ... Sometimes you can become fearful. Sometimes you become vain and sometimes you will seek power just for power's sake," he said.
Obama told the audience that people ask him, "`What role does faith play?' I say, `It plays every role."'
Last week, Obama attended services at a black Baptist church in West Columbia and a white Baptist church a few miles away in Columbia.
His campaign is in the midst of what it calls "40 Days of Faith & Family" an effort to introduce early voting South Carolina to how Obama's family life and faith have shaped his values.
In an interview with The Associated Press last week, Obama was asked about walking the line where politics and the pulpit meet.
"There are no set guidelines or play book. When I go to church, I go there to worship. I am perfectly content to sit and listen to the music and pray and listen to the sermon," Obama said after last weekend's church services.
Other times such as this Sunday Obama takes to the pulpit.
In those instances, he said, "my job is to try to draw a connection between the values that I express to the church and the challenges and issues that we face in politics. ... I don't think there's anything wrong with expressing faith in the public square and I think there's nothing wrong public servants expressing religiously rooted values."