President Obama lauded Friday's landmark decision by the Supreme Court -- which declared same-sex couples have a right to marry in all 50 states -- calling it a "victory for America" and describing the 5-4 ruling as "justice that arrives like a thunderbolt."

"This morning, the Supreme Court recognized that the Constitution guarantees marriage equality," Obama said. "In doing so, they have reaffirmed that all Americans are entitled to the equal protection of the law; that all people should be treated equally, regardless of who they are or who they love.

"Today we can say in no uncertain terms that we made our union a little more perfect," he said. "What an extraordinary achievement."

The president spoke from the White House Rose Garden shortly after a divided Supreme Court ruled 5-4 in favor of same-sex marriages anywhere in the United States. Justice Anthony Kennedy wrote for the majority, with the four liberal justices.

"No union is more profound than marriage, for it embodies the highest ideals of love, fidelity, devotion, sacrifice and family," Kennedy wrote. "In forming a marital union, two people become something greater than they once were."

"Their hope," he wrote, "is not to be condemned to live in loneliness, excluded from one of civilization's oldest institutions. They ask for equal dignity in the eyes of the law. The Constitution grants them that right."

It was not until 2012 that Obama announced his own support for gay marriage. Now, he says, the court ruling will end the patchwork of laws on marriage across the country and the uncertainty that they create for same-sex couples.

Immediately after the ruling, Obama tweeted: "Today is a big step in our march toward equality. Gay and lesbian couples now have the right to marry, just like anyone else. #LoveWins"

While praising Friday's ruling, Obama also acknowledged strong opposition to it and asked Americans to be "mindful" of differing views.

"I know that Americans of good will continue to hold a wide range of views on this issue," Obama said. "Opposition, in some cases, has been based on sincere and deeply held beliefs. All of us who welcome today's news should be mindful of that fact and recognize different viewpoints, revere our deep commitment to religious freedom."

The Associated Press contributed to this report.