President Obama hoped that announcing his change of heart in favor of same-sex marriage would put the issue to rest as a topic in his bid for re-election.

The immediate result, however, was that both sides seized upon it as an opportunity to energize their bases.

On the left, there was jubilation over Obama’s declaration that he now believes that “same-sex couples should be able to get married.” There was also hope that his stance will energize liberals and young voters, whose flagging enthusiasm Obama will need to rekindle this fall.

From the right came a call to arms that could make it easier for Mitt Romney, the all-but-certain GOP nominee, to rally conservatives who have been lukewarm to his candidacy.

But amid the initial furor, there was also a recognition — by both parties — that there is danger in inflaming passions and raising expectations about one of the most volatile social and cultural issues of the day.

“No one knows how [the political implications of Obama’s announcement] will play out,” said Chad Griffin, a major Democratic fundraiser who is set to take over in June as head of Human Rights Campaign, a leading organization lobbying for lesbian, gay, bisexual and transgender rights. “I expect this issue to really die down, and we’ll be back to the issues of jobs and the economy.”

House Speaker John A. Boehner (R-Ohio) sounded a similar note.

“I’ve always believed that marriage was between a man and a woman,” Boehner told Fox Business Network. “The Republicans here on Capitol Hill are focused in on the economy. The American people are still asking ‘Where are the jobs?’ and our focus is going to continue to be on the economy like it has been for the last year and a half.”

And while Romney reaffirmed his opposition to gay marriage at a campaign stop in Oklahoma, he did so cautiously, noting that it is “a very tender and sensitive topic, as are many social issues.”

When the question has been put to the voters over the past decade — more than 30 times in state referendums since 1988 — they have come down against gay marriage every time. In 2004, there were questions defining marriage on 11 state ballots, which helped the reelection effort of President George W. Bush by boosting evangelical-voter turnout.

Three-quarters of the states now ban gay marriage in some fashion. Just a day before Obama’s announcement, North Carolina voters approved by an overwhelming margin adding a ban to their state constitution.

But attitudes are shifting, and there is a growing acceptance of same-sex unions. In the past year, almost every major poll has shown that a slim majority now supports them as a right. In March, for instance, a Washington Post-ABC News survey found that 52 percent said gay marriage should be legal, while 43 percent said it should be illegal.

That overall support, however, masked a deep partisan divide. Democrats overwhelmingly supported gay marriage, by 64 to 32 percent, and independents by a narrower 54 to 42 percent. Republicans opposed it, by 57 to 39 percent.

Just as significant is the gap among age groups. Young voters are far more likely to support the idea of gay marriage, no matter their party affiliation, while older ones more frequently oppose it.

Senate Majority Leader Harry M. Reid (D-Nev.) noted that generational divide in a statement in which he said that while he does not oppose anyone being allowed to marry whomever they want, “my personal belief is that marriage is between a man and a woman.”

But he added: “In talking with my children and grandchildren, it has become clear to me they take marriage equality as a given. I have no doubt that their view will carry the future.”

The downside political risk of Obama’s announcement is mitigated by the fact that he is unlikely to lose many African American voters over it, despite the fact that they are decidedly skeptical of gay marriage. In the last year of polling by the Post and ABC News, just 42 percent of African Americans said they support legalization, while 55 percent oppose it.

One area where the announcement could help Obama is in fundraising. About one in six of his biggest fundraisers — those who have brought in $500,000 and more — publicly identify themselves as gay.

But some liberal gay donors had threatened to withhold contributions over Obama’s stance on gay marriage.

“The phone’s been ringing off the hook” with calls from major donors since the president’s announcement, said Andrew Tobias, an openly gay Obama fundraiser who also serves as treasurer of the Democratic National Committee.

Within hours of his shift, Obama’s campaign sent out a mass e-mail touting his new position and seeking donations.

That, however, raises the question of whether Obama’s announcement has heightened expectations that he will do more to further the cause of gay marriage — campaigning for it in states, such as Maryland, which is holding a referendum this fall, or pushing federal legislation.

“I don’t think anyone thinks the president is going to stop being the president, and turn into a full-time LGBT [lesbian, gay, bisexual, transgender] activist,” Griffin said. “There is not a lot more than can be done from a federal perspective,” as long as there is not a majority in Congress for gay marriage.

But Ralph Reed, a longtime Republican strategist who heads the evangelical Faith and Freedom Coalition, insisted that the damage has been done.

“At a time of high unemployment and severe economic distress, President Obama chose the week he launched his re-election campaign to flip-flop on same-sex marriage,” Reed said in a statement. “This is an unanticipated gift to the Romney campaign. It will alienate voters who believe he does not share their values and is certain to fuel a record turnout of voters of faith to the polls this November.”

Polling analyst Peyton Craighill and staff writer Dan Eggen contributed to this report.