He becomes the first American president to support same-sex marriage.
Supporters hail the historic moment in civil rights history.
Obama said his position had evolved partly after talking to his two daughters Malia and Sasha.
Political anlysts have warned that Obama could be entering a political minefield just as the election season heats up.
Barack Obama became the first US president Wednesday to say publicly he was in favor of same-sex marriage, in a high-stakes intervention in a pre-election debate roiling American politics.
In what supporters will hail as a historic moment in civil rights history, Obama changed his stance, after previously saying he was "evolving" on gay marriage, a fiercely divisive issue in US politics.
"I've just concluded, 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, who had previously backed strong protections for gay and lesbian couples, said his position had evolved partly after talking to his two daughters Malia and Sasha who had some friends who had same-sex parents.
"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 said in the interview.
Obama came under increasing political pressure on gay marriage after Vice President Joe Biden said on NBC's Meet the Press on Sunday that he was "absolutely comfortable" with same-sex marriage.
Education Secretary Arne Duncan said this week that he was also in favor of the concept.
Some political analysts have warned that Obama could be entering a political minefield, with some key voting blocs in swing states that he hopes to court in November's election opposing gay marriage.
On Tuesday, voters in North Carolina, a state Obama narrowly carried in the 2008 election, approved a state constitutional amendment forbidding gay marriages, civil unions and domestic partnerships.
The measure was passed by 61 percent to 39 percent after similar state constitutional amendments have been approved in some 30 US states.
The amendment solidifies and expands already enacted North Carolina law forbidding same-sex marriage.
Obama came to the position he elucidated on Wednesday through a long period of reflection and following pressure from his political base, which includes gay and lesbian groups.
In 2004, he said for religious reasons that he believed that "marriage is between a man and a woman," but added that he favored a "bundle" of civil rights for gays and lesbians.
"What I believe in my faith ... a man and a woman when they get married are performing something before God."
In 2010, Obama said "my feelings are constantly evolving" on gay marriage, and said he was in favor of civil unions for gays and lesbians that have strong civil protections.
In 2011, Obama said he was "still working on it."