Same-sex marriage supporters rejoice outside the Supreme Court, June 26, 2015. Alex Wong/Getty Images

For more than 20 years, the campaign to legalize same-sex marriage nationwide has been inching strategically toward the Supreme Court. And Friday, that strategy paid off: Same-sex couples can now get married in every state.

The Court's 5-4 ruling wasn't that surprising; for the past year or two, it even looked like a foregone conclusion. But the historic victory for gay couples didn't just happen; Justice Anthony Kennedy didn't simply wake up one day and decide it was time. It was the culmination of a long, intensive, and deliberate campaign.

Part of the strategy was to build public support; part of it was to win legislative victories in the states. But the ultimate target was always the Supreme Court.

"(I've) always said, the way we're going to win was building toward a Supreme Court ruling," said Evan Wolfson, the founder and president of Freedom to Marry. "We never believed we were going to have to win in every single state, plodding our way through Mississippi in 2030."

Wolfson has been on the front lines of the marriage-equality fight literally as long as it has been a fight. He founded Freedom to Marry in 2003, when the more established gay-rights organizations largely were focused elsewhere. The plan to get same-sex marriage legalized was primarily his brainchild—and at times, he was almost its only defender.

"There were certainly plenty of points where people told me it wouldn't work, but I always believed we could do this. I always believed this was the right strategy," Wolfson said in an interview conducted before the Supreme Court's ruling Friday.

The ball got rolling slowly. In the '90s, a challenge to Hawaii's ban on same-sex marriage seemed to be making progress—but then voters in the state approved a constitutional amendment that abruptly cut short the push for marriage equality there. (The same success and setback would be repeated a decade later in California, where Proposition 8 effectively reversed a state Supreme Court decision allowing same-sex marriage.)

The first real legal breakthrough came in 2003, when the Massachusetts Supreme Court ruled that a ban on same-sex marriage violated the state constitution. "Civil marriage is an esteemed institution, and the decision whether and whom to marry is among life's momentous acts of self-definition," Judge Margaret Marshall wrote in one widely quoted section of the ruling.

For every step forward, though, there were setbacks. The 2000s saw roller coasters of activity, often reversing course even within one state.

Wolfson recalls one "particularly horrible" month in 2006, when Freedom to Marry and its allies lost four consecutive cases—in New York, New Jersey, Maryland, and Washington. They would later win marriage equality in each of those states through legislation, but the litigation losses took a toll.

"We were being strategic, but none of it is easy," Wolfson said.

Proposition 8 passed in 2008; but then 2009 turned out to be the movement's most successful year yet, with victories in four states. One of them was Maine, where the victory was erased at the ballot box in 2009, Wolfson said, then restored via another ballot initiative in 2012.

Thanks largely to legislative wins, including a major victory in New York, Wolfson felt that momentum already was on his side in 2013, when the Supreme Court agreed to hear challenges to California's Proposition 8 and the Defense of Marriage Act, the law that prohibited same-sex couples from receiving federal marriage benefits.

The court punted on Proposition 8, effectively allowing same-sex marriage to proceed in California without answering the broader question of whether the Constitution forbade states from banning it. But Kennedy's decision striking down the critical part of DOMA was nevertheless a clear signal that the court was on the side of marriage equality, and even Kennedy's critics said a nationwide ruling appeared to only be a matter of time.

"One of my main concerns was people pronouncing it inevitable too early," Wolfson recalled. "I used to say, 'Ten minutes ago they were telling us it's impossible; now theyre telling us it's inevitable' "¦ Both are ways of excusing yourself from doing the work."

But even Wolfson was surprised at the torrent of lower-court rulings that followed the Supreme Court's DOMA decision. Kennedy's opinion—both in its holding and its rhetoric—had opened a floodgate.

"What we didn't really fully know was how quickly the courts would embrace the case and start ruling in our favor," he said. "I don't know that anybody would have sat there and said, 'We're going to win 65 [cases] in the next two years.'"

But they did. One of the first—and Wolfson's sentimental favorite—was in Utah. That ruling contained Wolfson's favorite passage in all 65 post-DOMA victories: "It is not the constitution that has changed, its our knowledge of what it means to be gay or lesbian."

Kennedy sounded a similar note on Friday when he delivered the one big, final legal victory that Wolfson had been angling for.

"The limitation of marriage to opposite-sex couples may long have seemed natural and just, but its inconsistency with the central meaning of the fundamental right to marry is now manifest," Kennedy wrote.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.