The pair have contrasting approaches to discussing their faith
US presidential hopefuls John McCain and Barack Obama have been trying to woo Christian voters at a televised religious forum in California.
The two men shared a stage for the first time since securing nomination.
Speaking first, Mr Obama defended his support for abortion and same-sex civil unions, but said marriage should only be between a man and a woman.
Republican John McCain affirmed he was pro-life and that he strongly supported preserving the status of marriage.
The forum, hosted by US pastor Rick Warren, was the senators' last joint appearance before their official nomination as the candidates for November's presidential election at their respective party conventions in a few weeks.
Three debates are scheduled to take place after the Democrat and Republican conventions.
Mr Warren is best known for building Saddleback Church into a 20,000-member "mega-church" in Lake Forest, southern California, and for writing The Purpose-Driven Life.
Senator John McCain answers his questions on faith
At the beginning of the first hour-long interview, Mr Obama told the pastor that America's greatest moral failure was its insufficient help to the disadvantaged.
The Democratic candidate noted that the Bible had quoted Jesus as saying: "Whatever you do for the least of my brothers, you do for me."
He said the maxim should apply to victims of poverty, sexism and racism.
Mr Obama also reaffirmed his belief that marriage should only be a "union between a man and a woman", although he also defended his support for same-sex civil unions and for the granting of similar rights to same-sex partners.
If he were president, he said he would not support a constitutional amendment banning gay marriage because the issue was one for state governments to decide.
On abortion, Mr Obama stressed he remained pro-choice and that he believed in the "Roe vs Wade" Supreme Court ruling supporting it.
However, he did say that he would seek to reduce the number of late-term abortions and unwanted pregnancies.
Mr McCain was asked similar questions by Mr Warren. When asked about America's greatest moral shortcoming, he responded by saying that its citizens had failed to "devote ourselves to causes greater than our self-interests".
Barack Obama was questioned over religion
Appearing to criticise President George W Bush, Mr McCain said that after 11 September 2001 there should have been a push to encourage people to join the army, Peace Corps and other voluntary organisations, rather than an official call to "go shopping".
When asked about his stance on abortion, the Republican candidate declared he opposed abortion "from the moment of conception".
"I will be a pro-life president and this presidency will have pro-life policies. That's my commitment to you," he said to applause.
Mr McCain also said he supported preserving "the unique status of marriage between a man and a woman" and that he was against the decision taken in some states to allow same-sex marriages.
"That doesn't mean people can't enter into legal agreements. That doesn't mean that they don't have the right of all citizens," he said.
Conservative Christians form about one-quarter of the US electorate. They largely support the Republican Party, but have not shown great enthusiasm for Mr McCain.
He identifies himself as Baptist and has made a strong appeal to social conservatives and evangelical Christians during his campaign.
But he rarely discusses his faith. Earlier this year he said: "I'm unashamed and unembarrassed about my deep faith in God. But I do not obviously try to impose my views on others."
Mr Obama, a Christian, has made a point of discussing his religion on the campaign trail and has been courting religious voters with a presence on Christian radio and blogs, and other events.
Are you are Christian voter in the US? Which candidate has impressed you the most? Send us your views and experiences using the form below:
The BBC may edit your comments and not all emails will be published. Your comments may be published on any BBC media worldwide.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.