President Obama lauded the Supreme Court ruling in favor of same-sex marriage at the White House Friday. Here are key moments from President Obama's speech. (AP)

President Obama on Friday hailed the Supreme Court's ruling to protect the rights of same-sex couples to marry, declaring that the decision has "made our union a little more perfect."

Obama spoke in the Rose Garden shortly after the decision was announced and he cast the ruling as a historic moment in American history that capped decades of progress for the gay and lesbian community, sometimes driven by "anonymous heroes" who endured taunts and bullying.

"Sometimes there are days like this when that slow and steady effort is rewarded with justice that arrives like a thunderbolt," Obama said. Although the progress might have seemed slow to gay rights advocates, he added, the nation's shift on same-sex marriage has been "so quick."

[Read Obama's full remarks here.]

He noted that many Americans still oppose it out of deeply-held religious beliefs and that the nation should be mindful to respect different viewpoints. But he added that the ruling "also gives us hope that on many issues with which we grapple, real change is possible. A shift of hearts and minds is possible."

Before making his remarks, Obama phoned the lead plaintiff in the case, Jim Obergefell, to congratulate him on the decision and thank him for his efforts. "I'm proud of you and your husband," Obama told him. The call was captured live on CNN, which had been interviewing Obergefell.

Obama also sent a message on his personal Twitter account, using the hashtag #LoveWins.

Obama has wrestled personally with gay marriage, having said he supported civil unions -- but not same-sex marriage -- as a candidate for the White House in 2008. He said that his views as a Christian were that marriage was defined as between a man and a woman.

[Live updates: Supreme Court rules gay couples nationwide have a right to marry]

As he geared up for re-election in 2012, however, Obama said his views were "evolving," as he sought to build supports in the gay community. Though gay rights activists were frustrated by the president's unwillingness to fully endorse same-sex marriage, they hailed his commitment to ending discrimination, including his successful push to get Congress to repeal the "don't ask, don't tell" policy banning openly gay service members in the military.

Obama finally endorsed same-sex marriage in 2012, becoming the first U.S. president to fully embrace that level of civil rights for gays. “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 at the time.

In a book published in February, longtime Obama political adviser David Axelrod wrote that Obama had hidden his true support for same-sex marriage in 2008 because it was politically expedient. Obama disputed that account in an interview with BuzzFeed News that same month.

“I think David is mixing up my personal feelings with my position on the issue,” Obama said in the interview. “I always felt that same-sex couples should be able to enjoy the same rights, legally, as anybody else and so it was frustrating to me not to, I think, be able to square that with what were a whole bunch of religious sensitivities out there.”

In the Rose Garden, Obama said the court ruling would end the "patchwork" system of local laws on same-sex marriage and end the uncertainty facing gay and lesbian couples. He cited Robert Kennedy when he said that small actions can be like a pebble thrown into a still lake.

"Ripples of hope cascade outward and change the world," Obama said.