Though the decision was fraught with political calculations, Obama's move was seen and praised by supporters as a watershed moment in American society's growing acceptance of equal rights for gay people.
The president said he was led to change his mind after reflecting on the relationships of gay friends as well as conversations with his wife and two daughters. He told of feeling torn between a belief that people should be treated equally, and a respect for the religious convictions of many who oppose gay marriage.
"I had hesitated on gay marriage in part because I thought that civil unions would be sufficient," Obama said. "I was sensitive to the fact that for a lot of people, the word marriage was something that invokes very powerful traditions and religious beliefs."
Though strategists believe the November election will turn on the sluggish economy, Obama's embrace of marriage equality carries political risks and creates a sharp contrast with Republican opponent Mitt Romney, who opposes allowing gays to wed and backs an amendment to the Constitution barring it.
Obama's position could offend conservative Democrats and independents in battleground states such as Virginia and North Carolina - the latter being where 61 percent of voters approved a state constitutional amendment Tuesday to ban gay marriage.
In addition, polls have shown many African American voters oppose same-sex marriage. Obama needs a huge turnout of black voters if he is to reassemble his winning coalition from 2008.
Those who believe Obama has held this view all along point to his answer in 1996 on a questionnaire when he was a candidate for the Illinois legislature: He indicated support for gay marriage. When he ran for the Senate in 2004, however, he opposed it, a stance he maintained as a presidential candidate and in the White House. Instead, he has backed civil unions that would extend to same-sex couples rights and privileges similar to those of heterosexual married couples.
After a campaign speech Wednesday in Oklahoma City, Romney stressed that he had been consistently opposed to gay marriage. As governor of Massachusetts, he resisted a state Supreme Court decision legalizing it.
"This is a very tender and sensitive topic," Romney said, "as are many social issues. But I have the same view I've had since, well, since running for office."
For Romney, who has battled perceptions that he moved to the right on social issues out of political expediency, Obama's words offer a chance to undercut that critique by portraying the president as the flip-flopper.
"He previously said he opposed same-sex marriage," Romney said when asked if Obama was inconsistent. "You'll be able to make that determination on your own."
Obama had been under pressure from his left to change his position, and was widely assumed to be planning a way to finesse it. Some Democrats are pushing to have a same-sex marriage plank included in the party platform at its convention this summer. Liberal donors, including prominent gay activists, were restive and some threatened to withhold donations from Obama and super PACs operating on his behalf.
On Thursday, Obama is to attend a reception at the actor George Clooney's home, expected to gather $12 million in campaign funds from Hollywood celebrities, many of them active in gay-rights groups. The president also is to raise money Monday at the Lesbian, Gay, Bisexual and Transgender Leadership Council in New York City with the actor and singer Ricky Martin, who is gay, as a special guest.
The pressure on Obama to take a stand was ratcheted up Sunday when Vice President Biden said on Meet the Press that he would be "absolutely comfortable" allowing gay couples to marry. Soon thereafter, two cabinet members also voiced support.
As for calculations regarding his political base, senior Democrats said it was hard to imagine large numbers of black voters deserting Obama over the issue. But the move could energize evangelical voters and other social conservatives who had been reluctant to rally around Romney, the presumptive GOP nominee, in part because of his past moderate positions.
"This is an unanticipated gift," Ralph Reed, founder and chairman of the Faith and Freedom Coalition, said. "It is certain to fuel a record turnout of voters of faith to the polls this November."
Keith Appell, a GOP consultant in Washington, said the shift raised "a real red flag" about Obama's politics. "He feels that he has to cast his lot with Democratic donors as opposed to Democratic voters," Appell said. "It was a grenade that landed in his lap."
Appell noted that about 20 percent of North Carolina primary voters picked "no preference" over Obama Tuesday, while about 40 percent in West Virginia's Democratic primary voted for a federal inmate who ran as a protest candidate against the president.
The immediate impact of Obama's words was far more political and social than legal. He proposed no legislation and signed no order; in fact, he stressed that he was expressing a personal opinion, and believes states should be able to define marriage without federal interference.
That is the same position then-Vice President Dick Cheney took in 2004, when GOP strategists were counting on gay-marriage ballot initiatives to rally their party's base.
If Obama's stance has "evolved," so has that of most Americans. While opinion is split on gay marriage, support has risen in recent years.
Forty-seven percent of Americans now favor gay marriage; 43 percent oppose it, according to a recent Pew Research survey. In 2004, Pew found 60 percent opposed. A Gallup poll released this week found 50 percent of adults in favor. Most Democrats (65 percent) and independents (57 percent) supported legalization; 74 percent of Republicans were opposed.
Still, voters have rejected gay marriage 32 times since 1998. Thirty-eight states prohibit it in some fashion. Even in "blue" states like California, Oregon and Delaware, gay marriage bans stand. Eight states and the District of Columbia permit same-sex marriages. Maryland and Washington state approved it this year, while New York did last year.
Legislative leaders in New Jersey made gay marriage their top priority this year, numbering the bill symbolically as "1" in both the Assembly and Senate, which are controlled by Democrats. The bill was passed in February. But Republican Gov. Christie conditionally vetoed it, saying voters should decide in a referendum. Christie also said he'd prefer to strengthen the state's 2007 civil-unions law.
In Pennsylvania, where outstate voters tend to be more socially conservative, gay marriage is illegal.
Any doubt that the 44th president will tout his stance was erased Wednesday night. Next to a plea for donations, his campaign website trumpeted these words: " 'Same-sex couples should be able to get married.' - Barack Obama."
Contact Thomas Fitzgerald at 215-854-2718 or email@example.com, or @tomfitzgerald on Twitter. Read his blog, "The Big Tent," at www.philly.com/bigtent.
Inquirer staff writer Joelle Farrell and Inquirer wire services contributed to this article.