The Supreme Court ruled on Friday that state bans on marriage among same-sex couples are unconstitutional, a historic decision that caps off a rapid change in public opinion on gay marriage.

In a 5-4 decision, the court decided that states can no longer limit the right to marry to heterosexual couples. Before the decision, 13 states banned same-sex marriage, mostly in the Midwest and South.

“The court now holds that same-sex couples may exercise the fundamental right to marry. No longer may this liberty be denied to them,” Justice Anthony Kennedy wrote in the majority opinion.

How people outside the court reacted to the gay marriage ruling

ShareShare
Gay rights supporters celebrate after the U.S. Supreme Court ruled that the U.S. Constitution provides same-sex couples the right to marry, outside the Supreme Court building in Washington, June 26, 2015. With the ruling, gay marriage will become legal in all 50 states. REUTERS/Jim Bourg (Jim Bourg/Reuters)

Justices Ruth Bader Ginsburg, Stephen G. Breyer, Sonia Sotomayor and Elena Kagan joined Kennedy in the majority opinion, while Chief Justice John G. Robert Jr. and Justices Antonin Scalia, Clarence Thomas and Samuel A. Alito Jr. dissented.

State-by-state legalization of same-sex marriage has spread rapidly around the U.S. in the last few years. Eleven years ago, Massachusetts became the first state to legally recognize same-sex marriage.

As of earlier this week, same-sex couples could marry in 37 states and the District of Columbia. Recent surveys by the Public Religion Research Institute showed that over half of the states expressed majority support for same-sex marriage.

You might also like:

The Supreme Court's gay marriage decision explained in 60 seconds. (Gillian Brockell/The Washington Post)