The announcement, long sought by supporters of same-sex marriage, puts Obama squarely at odds with presumptive Republican presidential nominee Mitt Romney.
"At a certain point I've just concluded that for me, personally, it is important for me to go ahead and affirm that I think same-sex couples should be able to get married," Obama said in an interview with ABC News.
Obama once opposed same-sex marriage. He later indicated his views were "evolving." His announcement Wednesday in support of same-sex marriage was the first by a sitting president.
"I had hesitated on gay marriage, in part, because I thought civil unions would be sufficient," the president said. "I was sensitive to the fact that -- for a lot of people -- that the word marriage is something that provokes very powerful traditions and religious beliefs."
But, Obama said, his thinking shifted as he witnessed committed same-sex marriages and thought about U.S. service personnel who were "not able to commit themselves in a marriage."
It was not immediately clear how the development might play out at the voting booth.
A Gallup Poll released Tuesday indicated 50% of Americans believe same-sex marriages should be recognized by law as valid, with 48% saying such marriages should not be legal.
But a CNN/ORC poll, taken in late March, indicated policies towards gays and lesbians were tied for last in the most-important issues facing the country.
Obama was "disappointed" by Tuesday's vote on the issue in North Carolina, which he described as discriminatory against gays and lesbians, a spokesman said earlier Wednesday.
North Carolina voted to implement a state constitutional ban on same-sex marriage, which was already prohibited by state law. Supporters of the measure pushed for the constitutional amendment, arguing that it was needed to ward off future legal challenges.
The president said he supports the concept of states deciding the issue on their own, ABC News reported.
Obama said his daughters, Malia and Sasha, have friends whose parents are same-sex couples. "It wouldn't dawn on them that somehow their friends' parents would be treated differently. It doesn't make sense to them and frankly, that's the kind of thing that prompts a change in perspective."
Obama spoke Wednesday with ABC's Robin Roberts. The interview will appear on ABC's "Good Morning America" Thursday. Excerpts were to air Wednesday evening on "World News With Diane Sawyer."
The president's stance will be among many key differences with Romney, but it is not expected to be a key talking point in his campaign.
In comments Wednesday to CNN Denver affiliate KDVR, Romney reiterated his opposition to same-sex marriage.
"And I do not favor civil unions if they are identical to marriage other than by name," Romney said during a visit to Fort Lupton. "My view is the domestic partnership benefits, hospital visitation rights, and the like are appropriate, but that the others are not."
The Family Research Council criticized Obama, and its president said on CNN's "The Situation Room" that the decision will aid Romney.
"The president, I think, has handed to Mitt Romney the one missing piece in his campaign," said Tony Perkins. "That is the intensity and motivation that Mitt Romney needs among social conservatives to win this election."
An expert on religion and politics said the move will make "an already close election even closer."
"It cuts both ways -- it activates both Democratic and Republican base voters," said John Green of the University of Akron.
Obama told ABC that some opinions on the issue are "generational."
"When I go to college campuses, sometimes I talk to college Republicans who think that I have terrible policies on the economy, on foreign policy, but are very clear that when it comes to same-sex equality or, you know, sexual orientation, that they believe in equality," he said.
First lady Michelle Obama was involved in the president's decision.
"This is something that, you know, we've talked about over the years and she, you know, she feels the same way, she feels the same way that I do," Obama said.
The new president of the Human Rights Campaign lauded the development.
"President Obama's words today will be celebrated by generations to come," Chad Griffin said. "For the millions of young gay and lesbian Americans across this nation, their president's words provide genuine hope that they will be first generation to grow up with the freedom to fully pursue the American dream."
Obama's interview followed recent comments by other key administration figures.
Vice President Joe Biden said Sunday on NBC he was "absolutely comfortable" with couples of the same gender marrying, leading observers to wonder when Obama would again address the issue.
Education Secretary Arne Duncan on Monday also made headlines when he openly backed same-sex marriage rights. Asked on MSNBC's "Morning Joe" if he supports allowing individuals of the same gender to legally wed, Duncan replied: "Yes, I do."
Before Tuesday, 30 states had voted in favor of constitutional amendments that seek to defend traditional definitions of marriage as a heterosexual union.
Massachusetts, Connecticut, Iowa, Vermont, New Hampshire, New York and the District of Columbia issue marriage licenses to same-sex couples.
In February, Washington Gov. Christine Gregoire signed a bill that would legalize same-sex marriage beginning in June, but opponents there have pledged to block the bill and called for voters to decide the issue.
Maryland Gov. Martin O'Malley signed into law a bill that permits the state's same-sex couples to wed as of January 1, and state residents may vote to affirm such a law. Minnesota will vote on a state constitutional amendment similar to the one in North Carolina. Maine will have a referendum on allowing same-sex marriage.
In 2011, the Pentagon stopped enforcement of the "don't ask, don't tell" policy on homosexuals serving in the military. That change played a part in Obama's announced stance on same-sex marriage.
"When I think about those soldiers or airmen or Marines or sailors who are out there fighting on my behalf and yet feel constrained, even now that 'don't ask, don't tell' is gone, because they are not able to commit themselves in a marriage, at a certain point I've just concluded that for me personally it is important for me to go ahead and affirm that I think same sex couples should be able to get married," he told ABC News.
Legal challenges over same-sex marriage could reach the U.S. Supreme Court in coming months, but it seems unlikely justices would hear arguments before Election Day 2012.
The issue is on two legal tracks.
The Ninth Circuit U.S. Court of Appeals will decide the constitutionality of California Proposition 8, a voter-approved measure that would recognize marriage only between one man and one woman. A federal judge earlier struck down the law as a violation of equal protection, prompting the current appeal.
The Obama administration announced last year it believed the Defense of Marriage Act, often referred to as DOMA, to be unconstitutional. The law defines marriage for federal purposes as unions only between a man and woman.
A federal appeals court in Boston last month heard a DOMA lawsuit by a same-sex couple in Massachusetts. At issue is whether the federal government can deny tax, health and pension benefits to same-sex couples in states where they can marry.
That federal law is being officially defended in court by House Republicans, led by Speaker John Boehner, R-Ohio, who stepped in after the Justice Department refused to participate.
By the CNN Wire Staff.
CNN's Jessica Yellin, Bill Mears, Dan Gilgoff and Jim Acosta contributed to this report.
™ & © 2012 Cable News Network, Inc., a Time Warner Company. All rights reserved.