Mr. Obama has spoken out against Proposition 8, and opponents of the measure hope that a huge Democratic turnout in California on Nov. 4 — and, possibly, depressed turnout among conservatives — will help defeat it. At the same time, some Democrats say that if many socially conservative blacks and Hispanics turn out to support Mr. Obama, but oppose same-sex marriage, the amendment’s chances for passage could improve.

While same-sex marriage is not expected to play a consequential role in the elections on Tuesday — unlike in 2004, when a proposed ban in Ohio was widely seen as hurting the Democratic presidential nominee that year, Senator John Kerry — passions remain high for voters on both sides. Some gay Democrats had hoped, in particular, that Mr. Obama would extend his message of unity and tolerance to their fight on the issue.

“Barack is an intellectual guy, and I know he has been thinking through his position on gay marriage, and what is fair for all people,” said Michael Bauer, an openly gay fund-raiser for Mr. Obama and an adviser to his campaign on gay issues. “But he is just not there with us on this issue.”

Some gay allies of Mr. Obama thought, during a televised Democratic forum in Los Angeles in August 2007, that he might come out in favor of same-sex marriage, after he was asked if his position supporting civil unions but not same-sex marriage was tantamount to “separate but equal.”

“Look, when my parents got married in 1961, it would have been illegal for them to be married in a number of states in the South,” Mr. Obama said. “So, obviously, this is something that I understand intimately. It’s something that I care about.”

At that point, he veered onto legal rights, saying that — both in 1961 and today — it was more important to fight for nondiscrimination laws and employment protections than for marriage.

Mr. Obama has spoken only occasionally about his religious beliefs influencing his views on same-sex marriage, and he has indicated that he is wary of linking his religion to policy decisions.

Advertisement Continue reading the main story

“I’m a Christian,” Mr. Obama said on a radio program in his 2004 race for Senate. “And so, although I try not to have my religious beliefs dominate or determine my political views on this issue, I do believe that tradition, and my religious beliefs say that marriage is something sanctified between a man and a woman.”

Newsletter Sign Up Continue reading the main story Please verify you're not a robot by clicking the box. Invalid email address. Please re-enter. You must select a newsletter to subscribe to. Sign Up You will receive emails containing news content , updates and promotions from The New York Times. You may opt-out at any time. You agree to receive occasional updates and special offers for The New York Times's products and services. Thank you for subscribing. An error has occurred. Please try again later. View all New York Times newsletters.

In one of his books, “The Audacity of Hope,” however, Mr. Obama describes a conversation with a lesbian supporter who became upset when he cited his religious views to explain his opposition.

“She felt that by bringing religion into the equation, I was suggesting that she, and others like her, were somehow bad people,” he wrote. “I felt bad, and told her so in a return call. As I spoke to her, I was reminded that no matter how much Christians who oppose homosexuality may claim that they hate the sin but love the sinner, such a judgment inflicts pain on good people.”

“And I was reminded,” Mr. Obama added, “that it is my obligation, not only as an elected official in a pluralistic society but also as a Christian, to remain open to the possibility that my unwillingness to support gay marriage is misguided, just as I cannot claim infallibility in my support of abortion rights.”

Advisers to Mr. McCain, meanwhile, say that he is not especially fervent on the issue — he simply believes that marriage has always been between a man and a woman, and that this is a culturally accepted norm that he sees no need to dispute.

Mr. McCain discussed his views with the openly gay entertainer Ellen DeGeneres in an appearance on her television talk show in May.

The California Supreme Court had just cleared the way for same-sex marriage, and Ms. DeGeneres had announced on her program that she planned to marry her longtime girlfriend. “We are all the same people, all of us — you’re no different than I am,” Ms. DeGeneres told Mr. McCain as they sat next to each other in plush chairs. “Our love is the same.”

Mr. McCain called her comments “very eloquent” and added: “We just have a disagreement. And I, along with many, many others, wish you every happiness.”

Ms. DeGeneres said: “So, you’ll walk me down the aisle? Is that what you’re saying?”

Mr. McCain replied, “Touché.”

Advertisement Continue reading the main story

As a matter of policy, Mr. McCain approaches same-sex marriage from his strong federalist viewpoint. He was one of seven Republican senators to vote in June 2006 against a proposed federal amendment banning such marriages, saying it was an issue for the states. That same year, he also worked to try to amend Arizona’s Constitution to define marriage as between a man and a woman. That amendment failed — the first rejection in 28 statewide votes on similar measures since 1998; a new effort is on the ballot next week in Arizona, and Mr. McCain has endorsed it.

“He is a true federalist, seeing no need for the federal government to dictate laws on who can marry who,” said Jim Kolbe, a former Republican congressman from Arizona and a friend of Mr. McCain’s, and who is openly gay.

“As a personal matter, I think this is entirely a generational and cultural thing for him — he just doesn’t see a need for gay marriage,” Mr. Kolbe said. “I just think gay marriage is not part of the world and background that he comes from.”