Back in 1996, President Bill Clinton signed a law saying that the federal government would not recognize marriages between same-sex couples. On Friday night, the White House was illuminated with rainbow colors in celebration of the Supreme Court ruling legalizing such marriages in every state of the nation.

For gay-rights activists, the two decades between those moments were marked by a dramatic mix of setbacks and victories.

As recently as 2004, there was widespread despair among proponents as voters in 13 states approved constitutional amendments banning same-sex marriage. At that time, some activists questioned whether marriage equality was a realistic goal.

But as more gay people came out of the closet, more of their relatives and acquaintances became supportive of gay rights. Popular television shows such as ”Will and Grace” and ”Modern Family” accelerated acceptance with empathetic portrayals of gay characters. Opinion polls over the past 10 years showed a huge shift in attitudes toward same-sex marriage, which is now supported by 55 to 60 percent of Americans.

And over the past two years, a series of state and federal court rulings fueled hopes that victory was imminent.

U.S. District Judge Robert Shelby alluded to the public opinion shift in his December 2013 ruling striking down Utah’s ban on gay marriage as unconstitutional. ”It is not the Constitution that has changed, but the knowledge of what it means to be gay or lesbian,” he wrote.

President Barack Obama, who endorsed gay marriage in 2012, paid tribute to the persistence of its supporters in his remarks Friday.

”Sometimes two steps forward, one step back,” he said. ”And then sometimes there are days like this, when that slow, steady effort is rewarded with justice that arrives like a thunderbolt.”

Gay rights activism surfaced in the U.S. in the 1950s. The first gay-rights protest in front of the White House took place in 1965; police harassment of patrons at the Stonewall Inn, a New York City gay bar, sparked three days of riots in June 1969.

In the 1970s, gay activism expanded to encompass marriage.

The first lawsuit in the U.S. seeking same-sex marriage rights was filed in Minnesota by Jack Baker and Michael McConnell after a county clerk denied their application for a marriage license in 1970. On appeal, the case went all the way to the U.S. Supreme Court, which dismissed it.

”Finally, the Supreme Court affirmed the question we raised 44 years ago,” McConnell said in an email Saturday. ”I’m a patient man, but 44 years is a long time to wait for this intuitively obvious answer.”

Another couple, American Richard Adams and Australian Tony Sullivan, were able obtain a marriage license from a court clerk in Colorado in 1975. But federal authorities did not recognize the marriage, and rejected Sullivan’s efforts to remain in the U.S. as the spouse of a citizen. A letter from the Immigration and Naturalization Service said the couple ”failed to establish that a bona fide marital relationship can exist between two faggots.”

Over the past two decades, more than 30 states passed amendments banning gay marriage.

However, same-sex marriage began in Massachusetts in 2004 under an order from the state’s high court, and soon legislators and voters in other states were legalizing it without court pressure. At the time of Friday’s Supreme Court ruling, same-sex marriages were allowed in 36 states.

Among opponents, there was some amazement at how quickly gay marriage had become the law of the land.

”How did we reach a point where an institution older than recorded history could be redefined and altered by an idea unknown before the year 2000?” asked Andrew Walker, director of policy studies for the Southern Baptist Convention’s Ethics and Religious Liberty Commission.

Many gay-rights leaders said major challenges remain for their movement. A top priority is passage of a comprehensive federal law that would ban discrimination on the basis of sexual orientation or gender identity.

”We now have to work harder than ever before to make sure LGBT Americans cannot be fired, evicted or denied services simply on the basis of the marriage license that they fought so hard to achieve,” said Chad Griffin, president of the Human Rights Campaign.