WASHINGTON — When Bill Clinton was president, he waited until almost 1 in the morning in 1996 to sign a bill defining marriage as the union of a man and a woman. He did not like it, but was unwilling to veto it 45 days before an election.

Sixteen years later, President Obama endorsed same-sex marriage, a journey reflecting not just his own personal “evolution,” but also the dizzying pace of social change in an age of technology.

From the political arena to the courts, the emergence of same-sex marriage as a mainstream issue in less than a generation has upended convention, scrambled long-held assumptions and defied history. The kind of change that took other social movements decades or longer to achieve has accelerated in an era of instant communication and universal information.

What was unthinkable in the 1990s is increasingly commonplace as gay men and lesbians serve openly in the military and marry and adopt children, while the youngest generation wonders what all the fuss was about.

“We’ve had these successive movements of social change, from African-Americans, then feminism and now gay rights, and each one seems to happen faster than the last and you wonder what’s going on there,” said Jonathan Rauch, an author-scholar and an early proponent of same-sex marriage. “I do wonder if in a more connected society, people are more comfortable with change.”

Today, about 47 percent of Americans support same-sex marriage, compared with 43 percent who oppose it, according to the Pew Research Center. The 26-point swing in just a decade is a far more rapid change in public attitudes than on past social issues like interracial marriage. And more so perhaps than with race or gender, attitudes on gay rights seem likely to continue changing, given the broad acceptance found in polls among younger Americans, who will make up an increasing segment of the populace.

Yet even if support for gay rights has grown, it does not mean that the country has come to accept same-sex marriage, as indicated Tuesday by North Carolina’s passage of another state constitutional amendment banning it, the 31st such measure.

Indeed, nearly every time same-sex marriage has been put on a ballot, voters have rejected it, and several more states are likely to vote on constitutional bans later this year, including Maryland and Minnesota. Including statutory bans passed by legislatures, more than 40 states prohibit same-sex marriage, and their laws may be hard to unwind even if voter sentiments swing as polls suggest they are.

“Proponents of same-sex marriage have created a myth of inevitability, and folks in the polling world have used language that has often helped them,” said Brian S. Brown, president of the National Organization for Marriage, which opposes same-sex marriage. “The only poll that counts is the voters, and if you look at that, we’ve won every single one. If you look at trend lines, the trend lines are in our direction.”

Mr. Rauch agreed with opponents that the polls may overstate support for same-sex marriage at this point. But unlike with other social movements, he said, gay rights advocates have been able to change attitudes by fusing a liberal goal with a conservative value. By asking for the same right to form families, he said, gay men and lesbians were rejecting a more libertine image that turned off many other Americans.

“We’re seeing a shift in public morality,” he said.

As the issue plays out in the political arena, it is also heading to a climactic moment at the Supreme Court, which may soon be asked to weigh in just as it has in the past on rights for blacks and women. Separate cases are heading toward the court challenging a voter-approved ban in California and the federal law Mr. Clinton signed, called the Defense of Marriage Act. Even before his statement this week, Mr. Obama had ordered the Justice Department not to defend the law.

The Supreme Court is a wild card in the same-sex marriage debate. Lawyers widely believe there would be four justices on each side, leaving Justice Anthony M. Kennedy as the deciding vote. Like other parts of society, the court has changed its thinking over the years, particularly as justices have come to know gay men and lesbians personally. The late Justice Lewis F. Powell Jr., who when writing a ruling upholding a sodomy ban told a secretly gay clerk that he had never “met a homosexual,” later said his decision was a mistake.

Yet Justice Kennedy may be reluctant to insert the court into the middle of such a highly charged social issue without a national consensus, according to legal analysts. And some advocates of gay rights worry that even if the court did rule in their favor, it would risk setting off a backlash.

Eric J. Segall, a law professor at Georgia State University, said that by enshrining abortion rights in Roe v. Wade, before the country was ready, the court energized a conservative movement that elevated Ronald Reagan and Newt Gingrich.

“When the court gets involved in trying to make progressive change, it fails miserably,” he said.

Others believe that the pace of change fueled by technology has changed that equation, and that younger Americans are not likely to change their views as they age. The issue does not fall clearly along ideological lines. Long before Mr. Obama, former Vice President Dick Cheney and the former Republican National Committee chairman Ken Mehlman endorsed same-sex marriage, while many black members of the clergy who normally form the bedrock of the Democratic coalition have lobbied against it.

One of the lead lawyers fighting California’s ban is Theodore B. Olson, who argued the Florida vote recount case that cleared the way for George W. Bush to become president.

For that matter, the opponents of the Defense of Marriage Act now include former Representative Bob Barr, who as a Republican from Georgia first sponsored it in 1996. Mr. Barr, who left the party to become a libertarian, concluded in 2009 that the law improperly tied the hands of states that wanted to legalize same-sex marriage, and he has called for its repeal.