The Supreme Court on Tuesday, April 28, heard oral arguments over whether states' same-sex marriage bans are constitutional, setting the stage for a final decision on marriage equality by the end of June. Federal appeals courts have disagreed on whether states' bans violate the US Constitution's 14th Amendment, leaving it to the Supreme Court to decide the issue.

Same-sex marriages are already allowed in 37 states and Washington, DC, but many hinge on lower courts' decisions in favor of marriage equality.

The Supreme Court's marriage battle has been 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 have 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. Here's a look back at the history:

The cases could bring marriage equality to the entire US

Legal experts and LGBT advocates widely expect the Supreme Court to rule that states' same-sex marriage bans are unconstitutional — a decision that would effectively bring marriage equality to the US.

Justice Anthony Kennedy, who could act as the key swing vote in the court, 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 could apply 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 applies to state-level programs and benefits attached to marriage, and Kennedy appeared to invoke a similar argument in oral arguments, many court watchers expect 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. "It's hard to see how those same considerations wouldn't end up applying equally or even more forcefully to state marriage bans."

it's possible that not just Kennedy but Roberts could join the final decision in favor of marriage equality

Those considerations are particularly important, LGBT advocates argue, 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."

It's possible that the Supreme Court might not rule in favor of marriage equality. It could hand down a limited ruling that forces states to recognize but not grant same-sex marriage licenses. It could also uphold states' same-sex marriage bans, which would effectively reinstate bans in dozens of states and — potentially — rescind the marriages of couples who were married between the time lower courts allowed their unions and the final Supreme Court decision.

But as the history indicates, some of the key members of the Supreme Court have been signaling for some time now that they're prepared to make same-sex marriage rights the law of the land, leaving LGBT advocates very optimistic.

The arguments for and against come down to discrimination

Supporters of same-sex marriage argue that prohibiting gay and lesbian couples from marrying is inherently discriminatory and therefore violates the US Constitution's 14th Amendment, which require states enforce their laws equally among all groups. In the case of same-sex marriage, states' bans likely violate the 14th Amendment because they purposely exclude 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," 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."

Very similar arguments could be applied to states' same-sex marriage bans. In fact, the Supreme Court applied the 14th Amendment to its 2013 decision in United States v. Windsor, when it struck down the federal government's same-sex marriage ban.

Opponents of same-sex marriage argue that individual states are acting in the public interest by encouraging heterosexual relationships through marriage laws. The conservative Family Research Council, for instance, has 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, allows 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 is that states have a compelling interest to encourage heterosexual relationships without the explicit purpose of discriminating against gay and lesbian couples. If states have a compelling interest, the same-sex marriage bans may be allowed to stand. But if the bans are seen as discriminatory, the Supreme Court may interpret them as violating the 14th Amendment.

The compelling interest argument hasn't worked well in lower courts. Various federal appeals courts have come out in favor of marriage equality, while only one has ruled against it. Seventh Circuit Court of Appeals Judge Richard Posner, a Republican appointee, wrote in his court's majority opinion:

The argument that the states press hardest in defense of their prohibition of same-sex marriage is that the only reason government encourages marriage is to induce heterosexuals to marry so that there will be fewer "accidental births," which when they occur outside of marriage often lead to abandonment of the child to the mother (unaided by the father) or to foster care. Overlooked by this argument is that many of those abandoned children are adopted by homosexual couples, and those children would be better off both emotionally and economically if their adoptive parents were married.

Justice Kennedy, who's expected to act as the swing vote in the Supreme Court cases, similarly flipped the argument around when he wrote in 2013 that the federal same-sex marriage ban needed to be struck down because "it humiliates tens of thousands of children now being raised by same-sex couples." He also made a similar argument during oral hearings in the current cases. Kennedy's argument and the nearly unanimous decisions in the lower courts give LGBT advocates a lot of confidence that they're headed for a victory.

The cases are about two aspects of marriage equality

The Supreme Court has 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 gay and lesbian couples.

Kentucky has both types of cases, Michigan has a licensing case, Ohio has two recognition cases, and Tennessee has 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 .

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 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.

in Kentucky: Two same-sex couples filed a motion to intervene in so that Kentucky would allow them to marry in the state. A federal judge rolled 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.

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 have passed through the federal court system in the past few years. But the split in the federal appeals court has turned these six cases into quite possibly the most important for marriage equality.

Read the legal briefs to the Supreme Court

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

SCOTUSblog has 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:

Watch: How marriage equality swept the nation