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.