WASHINGTON -- In a historic decision, the U.S. Supreme Court ruled Friday that gay and lesbian couples across the country have a constitutional right to marry.
The 5-4 decision caps a long and often contentious battle over what many have called the “defining civil rights challenge of our time."
While the ruling, written by Justice Anthony Kennedy, recognizes a centuries-old “understanding” of marriage as “a union between two persons of the opposite sex,” it says “the history of marriage is one of both continuity and change.”
“That institution -- even as confined to opposite-sex relations -- has evolved over time,” the Supreme Court’s ruling says.
Writing the dissent, Justice Antonin Scalia called the ruling a “threat to American democracy.”
“Today’s decree says that my Ruler, and the Ruler of 320 million Americans coast-to-coast, is a majority of the nine lawyers on the Supreme Court.”
At least 36 states plus the District of Columbia currently recognize gay marriage in some form. The other states, meanwhile, passed state laws banning same-sex marriage.
Two questions in particular were facing the Supreme Court ahead of its decision: Does any part of the Fourteenth Amendment, with its guarantees of equal protection and due process, compel states to perform same-sex marriages? And -- if not -- are states required to at least recognize same-sex marriages performed in another state?
Public support for gay marriage has reached a new high, with 61 percent of respondents in an ABC News/Washington Post poll two months ago saying gay and lesbian couples should be allowed to legally marry.
President Obama delivered remarks following the decision, saying, "All Americans are entitled to the equal protection of the law." He also called it "a victory for America."
The case behind Friday’s decision began in 2013, after the Supreme Court ruled in a separate matter that same-sex spouses must be afforded the same federal benefits as other married couples. That ruling, though, did not tackle the question of whether gay marriage is a Constitutional right.
In the wake of the United States v. Windsor decision in 2013, Ohio real estate broker Jim Obergefell and his dying partner of 20 years were married in Maryland. But the state of Ohio, which has passed a ban on same-sex marriages, refused to recognize Obergefell as a “surviving spouse.”
The U.S. Court of Appeals for the Sixth Circuit backed the state of Ohio, ruling Ohio didn’t have to recognize same-sex marriages performed elsewhere.
Soon enough, the matter landed before the Supreme Court, consolidated with cases fighting over similar issues in Kentucky, Michigan and Tennessee.
The Supreme Court heard arguments in the case on April 28. As with many cases before the high court, many had expected moderate Kennedy to provide the deciding vote in Obergefell vs. Hodges.
During the arguments, Kennedy noted the definition of marriage as between a man and a woman “has been with us for millennia.”
“And it’s very difficult for the court to say, ‘Oh well, we know better,’” he said.
In 2004, Massachusetts became the first state to allow same-sex marriage. In the years since, as other states followed suit, the U.S. government extended certain benefits to same-sex couples.
And four years ago, the Defense Department ended its policy of “Don’t Ask, Don’t Tell,” allowing gay and bisexual soldiers to openly serve in the military.
“After decades of untold struggle, unyielding advocacy and unfathomable bravery, it is clear that we are in the midst of a national awakening,” Attorney General Loretta Lynch told an advocacy group this past week. “Of course, even as we celebrate remarkable advances, it is clear that we still have more work to do.”
ABC News’ Nancy Gabriner, Kate Shaw and Adam Teicholz contributed to this report
Get real-time updates as this story unfolds. To start, just "star" this story in ABC News' phone app. Download ABC News for iPhone here or ABC News for Android here.