The U.S. Supreme Court ruled on Friday that same-sex marriage is a nationwide right, making the court decision a landmark of the American gay rights movement.
The nation's highest court, in a narrow five-four decision, said the US Constitution requires all states to carry out and recognize marriage between people of the same sex.
President Barack Obama praised the ruling, in a fresh victory for the White House.
"Today is a big step in our march toward equality. Gay and lesbian couples now have the right to marry, just like anyone else," Obama tweeted with the hashtag "#LoveWins", as the White House changed its online avatar to the rainbow colors of the gay rights movement.
Flag-waving gay rights advocates outside the courthouse cheered the historic ruling and sang.
"The Fourteenth Amendment requires a state to license a marriage between two people of the same sex and to recognize a marriage between two people of the same sex when their marriage was lawfully licensed and performed out-of-State," the court said.
The case was brought by 14 same-sex couples who had challenged de facto bans on gay marriage in Michigan, Kentucky, Ohio and Tennessee.
All four states had insisted in their respective constitutions that marriage could only be a union between a man and a woman.
Marriage has been a core institution in society since ancient times, the court said, "but it has not stood in isolation from developments in law and society."
Excluding them from marriage, it said, denied same-sex couples "the constellation of benefits that the states have linked to marriage."
The court added: "Marriage embodies a love that may endure even past death.
"It would misunderstand these men and women to say they disrespect the idea of marriage... They ask for equal dignity in the eyes of the law. The Constitution grants them that right."
The decision came a year after the Supreme Court, in another major ruling, struck down a controversial federal law that denied US government benefits to wedded gays and lesbians.
Two months ago, people queued for days for a chance to hear the arguments that led to Friday's ruling, and activists for and against marriage equality rallied in front of the court.
At issue was the Supreme Court's interpretation of the 14th Amendment of the Constitution, which provides for equal protection under the law.
The nine justices had to decide if this amendment means states are required to recognize marriages that were conducted in other states.
The four states involved in the case, supported by religious and conservative organizations, argued that marriage is based on the biological compatibility