The Supreme Court on Friday agreed to hear a case that could bring about the end of same-sex marriage bans across the country.

The justices announced in an order that they will consider if state bans on gay marriage violate the Constitution’s guarantee of equal protection under the Fourteenth Amendment.

Oral arguments are likely to be heard in April — the justices allotted two and a half hours to the issue. And a decision is expected by the end of June.

The long-awaited move was triggered by a ruling at the 6th Circuit Court of Appeals, which became the first appeals court since the 2013 decision against the Defense of Marriage Act to uphold gay marriage bans in Michigan, Ohio, Kentucky and Tennessee. The Cincinnati-based 6th Circuit court had split with appellate courts at the 10th Circuit, 7th Circuit, 4th Circuit and 9th Circuit, all of which struck down gay marriage bans in the regions they cover.

Earlier this year the Supreme Court declined to take the cases, which paved the way for legal gay marriage in 30 states and the District of Columbia.

Justice Ruth Bader Ginsburg had indicated in September that “there will be some urgency” for the Supreme Court to step in if the 6th Circuit were to rule against same-sex marriage.

The Supreme Court announced two questions it will consider in the case:

1) Does the Fourteenth Amendment require a state to license a marriage between two people of the same sex? 2) Does the Fourteenth Amendment require a state to recognize a marriage between two people of the same sex when their marriage was lawfully licensed and performed out-of-state?

Gay rights advocates are optimistic. The Supreme Court has issued only three rulings in its history supporting the cause of gay rights — all three are since 1996, and the majority opinion in each one was written by Justice Anthony Kennedy. The most recent one, to require the federal government to recognize legal gay marriages, was decided in 2013 by a 5 to 4 vote.

The Obama administration will file a friend-of-the-court brief asking the Supreme Court to “urge the Supreme Court to make marriage equality a reality for all Americans,” U.S. Attorney General Eric Holder said in a statement on Friday. “It is time for our nation to take another critical step forward to ensure the fundamental equality of all Americans—no matter who they are, where they come from, or whom they love.”

This article was updated to include a statement from the Obama administration.