WASHINGTON — The Supreme Court on Friday agreed to decide whether all 50 states must allow gay and lesbian couples to marry, positioning it to resolve one of the great civil rights questions in a generation before its current term ends in June.

The decision came just months after the justices ducked the issue, refusing in October to hear appeals from rulings allowing same-sex marriage in five states. That decision, which was considered a major surprise, delivered a tacit victory for gay rights, immediately expanding the number of states with same-sex marriage to 24, along with the District of Columbia, up from 19.

Largely as a consequence of the Supreme Court’s decision not to act, the number of states allowing same-sex marriage has since grown to 36, and more than 70 percent of Americans live in places where gay couples can marry.

The cases the Supreme Court agreed to hear on Friday were brought by some 15 same-sex couples in four states. The plaintiffs said they have a fundamental right to marry and to be treated as opposite-sex couples are, adding that bans they challenged demeaned their dignity, imposed countless practical difficulties and inflicted particular harm on their children.

The pace of change on same-sex marriage, in both popular opinion and in the courts, has no parallel in the nation’s history.

Gay rights advocates hailed the court’s move on Friday as one of the final steps in a decades-long journey toward equal treatment, and they expressed confidence they would prevail.

“We are finally within sight of the day when same-sex couples across the country will be able to share equally in the joys, protections and responsibilities of marriage,” said Jon W. Davidson, the legal director of Lambda Legal.

Supporters of traditional marriage said the Supreme Court now has a chance to return the issue to voters and legislators.

“Lower court judges have robbed millions of people of their voice and vote on society’s most fundamental relationship — marriage,” said Tony Perkins, the president of the Family Research Council, a conservative policy and lobbying group. “There is nothing in the Constitution that empowers the courts to silence the people and impose a nationwide redefinition of marriage.”

The Supreme Court’s lack of action in October and its last three major gay rights rulings suggest that the court will rule in favor of same-sex marriage. But the court also has a history of caution in this area.

It agreed once before to hear a constitutional challenge to a same-sex marriage ban, in 2012 in a case called Hollingsworth v. Perry that involved California’s Proposition 8. At the time, nine states and the District of Columbia allowed same-sex couples to marry.

When the court’s ruling arrived in June 2013, the justices ducked, with a majority saying that the case was not properly before them, and none of them expressing a view on the ultimate question of whether the Constitution requires states to allow same-sex marriage.

But a second decision the same day, in United States v. Windsor, provided the movement for same-sex marriage with what turned out to be a powerful tailwind. The decision struck down the part of the Defense of Marriage Act that barred federal benefits for same-sex couples married in states that allowed such unions.

The Windsor decision was based partly on federalism grounds, with Justice Anthony M. Kennedy’s majority opinion stressing that state decisions on how to treat marriages deserved respect. But lower courts focused on other parts of his opinion, ones that emphasized the dignity of gay relationships and the harm that families of gay couples suffered from bans on same-sex marriage. In a remarkable and largely unbroken line of more than 40 decisions, state and federal courts relied on the Windsor decision to rule in favor of same-sex marriage.

The most important exception was a decision in November from a divided three-judge panel of the United States Court of Appeals for the Sixth Circuit, in Cincinnati. Writing for the majority, Judge Jeffrey S. Sutton said that voters and legislators, not judges, should decide the issue.

That decision created a split among the federal appeals courts, a criterion that the Supreme Court often looks to in deciding whether to hear a case. That criterion had been missing in October.

The Sixth Circuit’s decision upheld bans on same-sex marriage in Kentucky, Michigan, Ohio and Tennessee. The Supreme Court agreed to hear petitions seeking review from plaintiffs challenging those bans in each state.

The court said it will hear two and a half hours of argument, probably in the last week of April. The first 90 minutes will be devoted to the question of whether the Constitution requires states “to license a marriage between two people of the same sex.”

The last hour will concern a question that will be moot if the answer to the first one is yes: whether states must “recognize a marriage between two people of the same sex when their marriage was lawfully licensed and performed out of state.”

The court consolidated the four petitions, not all of which had addressed both questions.

“Ohio does not contest the validity of their out-of-state marriages,” the plaintiffs seeking to overturn the ban wrote in their brief seeking Supreme Court review. “It simply refuses to recognize them.”

State officials in Ohio had urged the justices to hear the case. “The present status quo is unsustainable,” they said. “The country deserves a nationwide answer to the question — one way or the other.”

Gov. Bill Haslam of Tennessee, a Republican, took a different approach from those of officials in the other states whose cases the Supreme Court agreed to decide. He did what litigants who have won in the lower court typically do: He urged the justices to decline to hear the case.

The Michigan case, DeBoer v. Snyder, No. 14-571, was brought by April DeBoer and Jayne Rowse, two nurses. They sued to challenge the state’s ban on same-sex marriage.

In urging the Supreme Court to hear their case, they asked the justices to do away with “the significant legal burdens and detriments imposed by denying marriage to same-sex couples, as well as the dignity and emotional well-being of the couples and any children they may have.”

Gov. Rick Snyder, a Republican, joined the plaintiffs in urging the Supreme Court to hear the case.

The Kentucky case, Bourke v. Beshear, No. 14-574, was brought by two sets of plaintiffs. The first group included four same-sex couples who had married in other states and who sought recognition of their unions. The second group, two couples, sought the right to marry in Kentucky.

In his response to the petition in the Supreme Court, Gov. Steven L. Beshear, a Democrat, said he had a duty to enforce the state’s laws. But he agreed that the Supreme Court should settle the matter and “resolve the issues creating the legal chaos that has resulted since Windsor.”

A version of this article appears in print on , on Page A1 of the New York edition with the headline: Justices to Decide Marriage Rights for Gay Couples. Order Reprints | Today’s Paper | Subscribe