It was such a historic breakthrough at the time. And so much has happened since then that it seems like ancient history. But it will only be two years next month since President Barack Obama finally came out in favor of same-sex marriage. In doing so, he was mirroring a broad and speedy change in public opinion on the issue, and would also accelerate it. Even so, when he did endorse gay marriage, in a May, 2012, interview with ABC News’s Robin Roberts, he said that he was expressing a personal view and equivocated on whether he believed marriage was a fundamental right guaranteed by the Constitution. And the following year, when his Administration filed a brief to the U.S. Supreme Court supporting the overturning of Proposition 8, California’s same-sex-marriage ban, Obama still held back. The brief did not advocate for a so-called fifty-state view that would guarantee gays and lesbians nationwide the right to marry.

On Wednesday morning, the New York Times Magazine published an excerpt from “Forcing the Spring: Inside the Fight for Marriage Equality,” a new book by Jo Becker that gives an inside account of the behind-the-scenes effort to get Obama to complete his long evolution on the issue. The book is to be published next Tuesday, and it sheds some important new light on what happened. Becker spent four years embedded with the team that brought the lawsuit trying to overturn Prop. 8, which was led by Theodore Olson and David Boies, and she was granted almost unlimited access on the promise that her account would not be published until after the case had finished. (The narrative here thus reflects the experiences of the key participants in the Prop. 8 lawsuit, at times perhaps disproportionately more so than the work of all the other important players.) In addition, Becker interviewed Obama insiders and Administration officials, including Vice-President Joseph Biden, and senior advisors Valerie Jarrett and David Axelrod, among others. (Becker also interviewed me for the book.)

Becker makes it clear that both Obama and his team were deeply conflicted about whether he should announce his support for gay marriage before the 2012 election, to the point where its unresolved, internal debate had resulted in a kind of paralysis. “His political advisers were worried that his endorsement could splinter the coalition needed to win a second term,” Becker writes. In the excerpt, Chad Griffin, the head of a group fighting Prop. 8, recounts a conversation that he had with First Lady Michelle Obama, during the summer of 2011: “Her message, he told his team, was clear: ‘Hang in there with us, and we’ll be with you after the election.’”

Even though Axelrod says that Obama “has never been comfortable” opposing same-sex marriage, it was not until Biden made some unscripted remarks in support of gay marriage on “Meet the Press,” in early May, 2012, that the President decided that he could no longer stay quiet, no longer occupy a permanent middle ground. His perpetual state of evolution on the issue was an untenable construct that he had maintained perhaps longer than was politically prudent. Biden’s surprise TV remarks were inspired by an emotional question-and-answer exchange that Biden had at an event in Los Angeles, at the home of a gay couple with two children, several days before the interview. Afterward, according to Becker, Valerie Jarrett was furious—even though she supported the President’s new position—and accused Biden of being disloyal for upstaging the President.

But for Michelle Obama, Becker writes, the whole Biden incident was a “blessing in disguise”: she recounts to aides that she told her husband, “Enjoy the day,” just before his interview with Roberts. “You are free.”

The President didn’t see it exactly that way, and was careful to couch his views in personal terms—as he has been advised to do by none other than Ken Mehlman, the former Republican National Committee Chairman and President George W. Bush’s political director, who was also working on the Prop. 8 case after having come out as gay. Obama ended up giving what Becker calls a “carefully calibrated and incremental endorsement,” saying in the interview: “I continue to believe that this is an issue that is going to be worked out at the local level, because historically this has not been a federal issue, what’s recognized as a marriage.” While the President’s statement proved hugely beneficial to the marriage-equality movement generally, his caveat ended up being a central element in the brief filed by the supporters of Prop. 8: their point was that even the President of the United States believed that people of good will could feel differently about same-sex marriage—that is, that it was not a simple matter of anti-gay discrimination—and that it was a state question, rather than a federal one.

That made it even more imperative that Olson, Boies, and Griffin get the President to weigh in specifically in support of their effort at the Supreme Court. What ensued was both a public and private lobbying campaign to get the Administration to file a brief supporting gay marriage more broadly. They needed Obama to “take one final step in his evolution … clearly stating that the administration believed that bans like Proposition 8 were not just bad policy, but they also violated the Constitution.”

Becker has talked to most of the important players at this point in the drama, including U.S. Solicitor General Donald B. Verrilli, Jr., who was responsible for the brief, and Attorney General Eric Holder, who describes in some detail the meeting at which he and Verrilli plotted Supreme Court strategy with the President, his White House counsel, and his chief of staff. Verrilli and Holder ended up recommending to Obama that they file a brief supporting same-sex marriage, but, according to the book excerpt, the President insisted upon giving the swing-vote Justice Anthony Kennedy a way to construct an incremental ruling. And so was born the “eight-state solution,” whereby the Justice Department argued that the Constitution required that gay marriage be allowed only in states that have granted broad domestic-partnership rights to same-sex couples—a position that left many scratching their heads, even though advocates were happy to have the government, in some sense at least, on their side.

The Supreme Court did reach a sweeping and historic decision the next summer, though not quite the one that the Prop. 8 team had been working toward. In their case, which started out center stage, the Justices ruled narrowly, and on procedural grounds, that the supporters of the gay-marriage ban lacked the requisite legal standing to pursue their appeal. This brought same-sex marriage back to California—but only to that state. A second case, a challenge to the Defense of Marriage Act brought by a widow named Edith Windsor, decided the same day, ended up creating a much more important legal precedent. (The Administration also filed a brief supporting Windsor, and had backed her case, beginning from the early appeals process.) The Windsor ruling has since formed the basis for dozens of federal equality lawsuits; by last count, there were sixty-four pending cases involving matrimonial laws in thirty states.

There are now seventeen states that recognize gay marriage, and five others where courts have declared bans on it unconstitutional but where the ruling has been stayed pending appeal. At the time of Obama’s announcement, there were six. The President’s support has been a significant factor in advancing the cause of marriage equality. Becker makes it clear that he often proceeded with characteristic caution, acting only at the last minute or when forced to do so—but ending up on the right side of history, and in plenty of time to make a big difference.

Richard Socarides is an attorney and longtime gay-rights advocate. He served in the White House during the Clinton Administration and has also been a political strategist. He now oversees public affairs at GLG. Opinions expressed here are only his own. Follow him on Twitter @Socarides.

Above: Barack Obama hosts a reception in honor of national Gay, Lesbian, Bisexual and Transgender Pride Month in June, 2012. Photograph by Chip Somodevilla/Getty.