In a landmark decision, the US Supreme Court on June 26 struck down states' same-sex marriage bans, effectively bringing marriage equality to the entire US.

"No union is more profound than marriage, for it embodies the highest ideals of love, fidelity, devotion, sacrifice, and family," Justice Anthony Kennedy, who joined the court's liberals in the majority opinion, wrote. "[The challengers] ask for equal dignity in the eyes of the law. The Constitution grants them that right."

The ruling, which five justices supported and four dissented against, means same-sex marriage is legal in all 50 states, and states will soon have to grant marriage licenses to all same-sex couples. Before the ruling, same-sex marriages were allowed in 37 states and Washington, DC.

Marriages should begin immediately or very soon in all states

The Supreme Court's decision means marriage equality is now the law of the land in the US. But whether states allow same-sex couples to marry immediately or days or weeks from now will depend on the actions of local and state officials, who could delay the final effect of the decision for a few days or weeks.

"What can happen and should happen is that states should start issuing marriage licenses almost immediately," James Esseks, director of the American Civil Liberties Union's LGBT and AIDS Project, said. "Once the Supreme Court rules, it's the law of the land, and they can go forward."

It's possible that some states will require federal courts that have already ruled on marriage equality to lift their stays on states granting marriage licenses. But that's something, Esseks said, that courts should be able to do pretty quickly. "A lot of trial judges put their decisions on hold while the appeals process worked out," he said. "Well, that's all happened now. So those judges can lift their stays right away."

Some state and local officials may require lower federal courts to issue new orders in favor of marriage equality to affirm a Supreme Court ruling, especially in states — like Alabama or Mississippi — that aren't directly linked to the cases the Supreme Court heard, which originated in Kentucky, Michigan, Ohio, and Tennessee. "There may be some time lag," Paul Smith, one of the nation's leading LGBTQ attorneys, said. "It could happen quickly, but in some states it may not."

It depends, then, on whether local and state officials try to obstruct the Supreme Court's ruling. "They may not choose to wait for an injunction to be issued," Camilla Taylor, marriage project director at Lambda Legal, an LGBTQ organization, said. "But we can definitely expect some foot-dragging in some states."

The Supreme Court's decision was years in the making

A flurry of legal challenges to states' same-sex marriage bans followed the Supreme Court's decision in June 2013 to strike down the Defense of Marriage Act, the federal ban on same-sex marriages. Since then, lower courts invoked the Supreme Court's ruling to end states' same-sex marriage bans under the argument that they violate the 14th Amendment's Due Process and Equal Protection Clauses, eventually leading to the Supreme Court case that was decided today. Here's a look back at the history:

There were many hints the Supreme Court would rule this way

Legal experts and LGBTQ advocates widely expected the Supreme Court to rule that states' same-sex marriage bans are unconstitutional, based on years of legal precedent in marriage cases.

Justice Kennedy, who wrote the majority opinion that ended states' same-sex marriage bans, also wrote the majority opinion in United States v. Windsor that struck down the federal ban on same-sex marriages in 2013 with a legal rationale that applied to states' bans. He argued that the federal ban violated constitutional protections and discriminated against same-sex couples by preventing them from fully accessing "laws pertaining to Social Security, housing, taxes, criminal sanctions, copyright, and veterans' benefits."

Because a similar legal argument applied to state-level programs and benefits attached to marriage, and Kennedy appeared to invoke a similar point in oral arguments, many court watchers expected Kennedy to rule against states' same-sex marriage bans, as well.

"The court was so focused on the tens of thousands of children being raised by same-sex parents and so sensitive to the ways those children are being disadvantaged and harmed and stigmatized," Shannon Minter, legal director at the National Center for Lesbian Rights, said prior to the court decision. "It's hard to see how those same considerations wouldn't end up applying equally or even more forcefully to state marriage bans."

Those considerations are particularly important, LGBTQ advocates argued, since the Supreme Court in October 2014 effectively legalized same-sex marriages in 11 states by refusing to hear appeals from cases originating in Utah, Oklahoma, Virginia, Wisconsin, and Indiana.

"It is almost inconceivable that having allowed so many couples to marry and so many families to gain the legal security and protection of marriage, the court would then roll back the clock," Minter said. "That would be not only cruel but chaotic."

Given the history, LGBTQ advocates were very optimistic about the ruling — and it looks like they were right.

The arguments for and against marriage equality came down to discrimination

Supporters of same-sex marriage argued that prohibiting gay and lesbian couples from marrying is inherently discriminatory and therefore violates the US Constitution's 14th Amendment, which require states to enforce their laws equally among all groups. In the case of same-sex marriage, states' bans violated the 14th Amendment because they purposely excluded gay and lesbian couples from marriage laws.

The 14th Amendment "was designed to, really, perfect the promise of the Declaration of Independence," Judith Schaeffer, vice president of the Constitutional Accountability Center, said. "The purpose and the meaning of the 14th Amendment is to make clear that no state can take any group of citizens and make them second-class."

In 1967, the Supreme Court applied both of these standards in Loving v. Virginia when the court decided that the 14th Amendment prohibits states from banning interracial couples from marrying.

"This case presents a constitutional question never addressed by this Court: whether a statutory scheme adopted by the State of Virginia to prevent marriages between persons solely on the basis of racial classifications violates the Equal Protection and Due Process Clauses of the Fourteenth Amendment," former Chief Justice Earl Warren wrote in the majority opinion at the time. "For reasons which seem to us to reflect the central meaning of those constitutional commands, we conclude that these statutes cannot stand consistently with the Fourteenth Amendment."

"The purpose and the meaning of the 14th Amendment is to make clear that no state can take any group of citizens and make them second-class"

A majority of justices at the Supreme Court concluded that very similar arguments applied to states' same-sex marriage bans, meaning that marriage is a fundamental right, the bans were discriminatory and unconstitutional, and states must carry out and recognize same-sex marriages.

Opponents of same-sex marriage, meanwhile, argued that individual states are acting in the public interest by encouraging heterosexual relationships through marriage laws. The conservative Family Research Council, for instance, warned that allowing same-sex couples to marry would lead to the breakdown of traditional families, and keeping marriage to heterosexual couples, FRC argued in an amicus brief, would allow states to "channel the potential procreative sexual activity of opposite-sex couples into stable relationships in which the children so procreated may be raised by their biological mothers and fathers."

The idea behind this type of argument was that states had a compelling interest to encourage heterosexual relationships without the explicit purpose of discriminating against gay and lesbian couples. If states had been found to have a compelling interest, the same-sex marriage bans may have been allowed to stand.

But the Supreme Court ultimately decided that states' bans did discriminate without a compelling interest, leading to a final decision in favor of marriage equality.

The cases in front of the Supreme Court covered various aspects of marriage equality

Prior to its ruling, the Supreme Court consolidated cases from Kentucky, Michigan, Ohio, and Tennessee that deal with two key issues: whether states should have to recognize — but not license — same-sex marriages from other states, and the broader issue of whether states should have to grant marriage licenses to same-sex couples.

Kentucky had both types of cases, Michigan had a licensing case, Ohio had two recognition cases, and Tennessee had a recognition case. Federal judges ruled in favor of same-sex couples in all these cases before the Sixth Circuit Court of Appeals ruled against them.

Here's a quick summary of each case, based largely on Freedom to Marry's great litigation tracker:

Bourke v. Beshear in Kentucky: Four same-sex couples sued Kentucky to have their out-of-state marriages recognized by the state. This lawsuit was later consolidated with Love v. Beshear.

Love v. Beshear in Kentucky: Two same-sex couples filed a motion to intervene in Bourke v. Beshear so that Kentucky would allow them to marry in the state. A federal judge rolled Bourke v. Beshear into this case.

DeBoer v. Snyder in Michigan: April DeBoer and Jayne Rowse sued Michigan so they could jointly adopt their three children, which the state prohibits. A judge later explained that the constitutional amendment that banned same-sex marriages in the state also prohibited the couples from adopting, prompting the couple to eventually expand their lawsuit to contest the state's same-sex marriage ban.

Obergefell v. Hodges in Ohio: James Obergefell and John Arthur sued Ohio so the state would recognize their marriage in the death certificate of Arthur, who was dying of amyotrophic lateral sclerosis. Arthur died in October 2013, as the court challenge was still pending.

Henry v. Hodges in Ohio: Four same-sex couples sued Ohio so both parents in a couple could have their names printed on their adopted children's birth certificates. (Under Ohio law, only one parent in a same-sex relationship can have his or her name printed on a birth certificate.) The case was later expanded to cover not just Ohio's birth certificate law, but whether the state should recognize same-sex couples' out-of-state marriages.

Tanco v. Haslam in Tennessee: Three same-sex couples sued Tennessee to have their out-of-state marriages recognized by the state.

These cases are a small sample of dozens of similar same-sex marriage lawsuits that passed through the federal court system in the past few years. But the split in the federal appeals court turned these six cases into the most important for marriage equality.

Read the Supreme Court's decision

Read the legal briefs to the Supreme Court

Dozens of organizations filed legal briefs to the Supreme Court in favor and against same-sex marriage.

SCOTUSblog helpfully compiled all the briefs for several cases:

Here are some of the amicus briefs filed by friends of the court, compiled by Freedom to Marry and SCOTUSblog:

Read the oral arguments to the Supreme Court

On April 28, the Supreme Court held oral arguments over the same-sex marriage cases.

You can listen to the oral arguments here:

You can also read the first part of the oral arguments here:

And here is the second part:

Watch: President Barack Obama speaks after the Supreme Court's decision in favor of marriage equality