For some gays, however, the politics were secondary to an emotional embrace of what they viewed as history in the making.
"Wow — that was wow," said Rodney Mondor of Portland, Maine, after hearing the news. He has lived with his partner for 13 years and is raising a 12-year-old son in a state that will be voting in November on whether to legalize same-sex marriage.
Gay-marriage supporters said Obama's pronouncement on Wednesday would galvanize legions of progressive voters who had grown impatient with the president's self-described "evolving" on one of the nation's most divisive social issues.
"There are, no doubt, some places where it will hurt him, and it may change his Electoral College strategy," said Richard Socarides, a former Clinton White House adviser on gay rights. "But ultimately it's a big plus for him — it highlights his willingness to tackle tough issues in a thoughtful but ultimately decisive way."
Opponents of gay marriage depicted Obama as bowing to gay-rights pressure, and predicted his new stance on marriage would jeopardize his re-election chances.
"President Obama has now made the definition of marriage a defining issue in the presidential contest, especially in swing states like Ohio, North Carolina, Virginia, Florida and Nevada," said Brian Brown, president of the National Organization for Marriage.
While six states have legalized gay marriage, and three more could do so this year, 30 states — including North Carolina on Tuesday — have passed constitutional amendments limiting marriage to unions of a man and a woman.
In Ohio, the head of a conservative group that approved such an amendment in 2004, predicted a backlash that would hurt Obama.
"He's going to lose Ohio and he's going to lose all the states that are huge on this issue," said Phil Burress, president of Citizens for Community Values. He advised Obama's presumptive Republican rival, Mitt Romney, to seize on the issue and campaign hard against gay marriage.
Chris Seelbach, elected last year as Cincinnati's first openly gay city councilman, suggested that Obama might lose some votes with his declaration, but will gain others.
"It will energize some of the people who have been waiting a long time for this and have been disappointed," he said. "Some of us are extremely proud today and ready to do whatever we can, do 120 per cent, to get him re-elected."
In addition to Maine, gay marriage may be on the Nov. 6 ballot in three other states.
Minnesota voters will be asked to decide on a ban-gay-marriage amendment similar to those in other states. In Maryland and Washington state, opponents of same-sex marriage are circulating petitions on behalf of proposed ballot measures that would overturn laws passed earlier this year to legalize same-sex marriage.
Zach Silk of Washington United for Marriage, a coalition that supports the gay marriage law, said Obama's remarks were "an enormous boost for us."
"It changes the way that the conversation will take place in the state," Silk said. "We expect voters in Washington will have a similar sort of evolution and similar sort of journey."
But a leader of the rival campaign said Obama's comments will boost efforts to overturn the gay-marriage law.
"This will galvanize and energize our folks," said Joseph Backholm, executive director of the Family Policy Institute of Washington. "This will help us make the case that national forces, including the president, are getting behind this effort to redefine marriage in Washington state."
Similar comments came from a leader of the Minnesota campaign to pass the amendment banning gay marriage.
"President Obama's statement demonstrates why marriage needs to be protected and put in the state constitution where politicians can't get at it," said Chuck Darrell, spokesman for Minnesotans for Marriage,
The spokeswoman for the pro-gay-marriage side, Kate Brickman of Minnesotans United for All Families, said Obama's pronouncement would be an asset.
"Obviously we're very pleased," she said. "If this sparks more conversations, that is a really great thing."
Reactions to Obama's remarks pervaded Facebook and Twitter.
Among the VIPs chiming in was Chai Feldblum, an openly gay member of the federal Equal Employment Opportunity Commission. She said in a tweet: "Just listened to my President affirm my right to get married to the love of my life."
From New York City, Mayor Michael Bloomberg called the decision "a major turning point in the history of American civil rights." He said the move is "a testament to the president's convictions."
Conversely, New York Cardinal Timothy Dolan, president of the U.S. Conference of Catholic Bishops, called Obama's decision "deeply saddening."
"I pray for the President every day, and will continue to pray that he and his administration act justly to uphold and protect marriage as the union of one man and one woman," Dolan said in a statement.
In Richmond, the capital of battleground state of Virginia, Obama's remarks delighted bed-and-breakfast owner Jeff Wells, whose same-sex marriage in Massachusetts is not recognized in Virginia.
"In my heart, I felt the president supported marriage equality, but I thought his decision not to speak publicly about it was politically motivated," said Wells. I was pleasantly surprised that he had the courage to do that ... It's gratifying to know that we are entering the 21st century on the right side of history."
In North Carolina, though, some gay-marriage supporters were bitter that Obama spoke out only after they lost the battle Tuesday against the marriage-ban amendment.
"He could have made that statement yesterday when it might have mattered here," said Danielle Horseley, 32, during a protest rally in Greensboro. "He could have come here and said that. I think it's cowardice he didn't."
Associated Press writers Michael Biesecker in Greensboro, N.C.; Steve Karnowski in Minneapolis; Dan Sewell in Cincinnati; Robert Lewis in Richmond, Va.; David Sharp in Portland, Maine, and Rachel La Corte in Olympia, Wash., contributed to this report.