Win McNamee/pool via Associated Press Supreme Court Chief Justice John Roberts, left, Associate Justice Stephen Breyer and Associate Justice Elena Kagan listens as President Donald Trump delivers his first State of the Union address on Jan. 30, 2018.

Chief Justice John Roberts was an instrumental force behind a 2012 Supreme Court decision to protect Obamacare but shifted his opinions on several key components of the health care law behind the scenes in the months leading up to the monumental decision, ultimately weakening the law in one critical place, according to an upcoming book about his life.

CNN’s Joan Biskupic detailed the backroom negotiations between Roberts and liberal members of the court in her new book, The Chief, which will be released later this month. In an excerpt posted on CNN’s website, Biskupic notes how Robert initially sided with the court’s conservative wing and voted in a private conference to reject a key argument the Obama administration had made in defense of the law’s individual mandate. The provision, a core part of the health care law, required Americans to purchase insurance or pay a penalty.

But Roberts was wary of overturning the whole law, as the conservative justices preferred, and over the next few weeks he began to construct an argument to present the individual mandate as a tax, according to Biskupic. The Obama administration had made that argument too, but it hadn’t come up in the initial conversation of the justices, according to the book excerpt.

Roberts eventually joined the court’s liberal justices, upholding the mandate on the grounds that it was a constitutionally permissible tax. This provoked outrage from his fellow conservatives and right-leaning lawmakers across the country.

Viewed only through a judicial lens, his moves were not consistent, and his legal arguments were not entirely coherent. But he brought people and their different interests together. His moves may have been good for the country at a time of division and a real crisis in health care, even as they engendered, in the years since, anger, confusion and distrust. Criticism on the right ― from insiders and outsiders ― was swift.

CBS’ Jan Crawford first reported Roberts’ change in 2012, shortly after the decision was handed down. The latest excerpt adds more detail to his reasoning and details the thinking of two liberal justices.

Although the decision on the mandate got the most attention at the time, the ruling also affected the Affordable Care Act’s expansion of Medicaid, under which all states were supposed to open up the program so that it would be available to anybody with income below or just above the poverty line.

The conservatives filing the lawsuit had claimed that provision of the Affordable Care Act was coercive to the states. In the initial conference, Biskupic reports, the four liberals rejected that argument and Roberts sided with them.

But here, too, Roberts had a change of heart and, according to Biskupic, two liberal justices, Elena Kagan and Stephen Breyer, perceived a deal in the making. They ended up voting with Roberts and the four other conservatives to invalidate part of the Medicaid expansion, effectively making that part of the Affordable Care Act optional for states.

Breyer and Kagan had voted in the private March conference to uphold the new Medicaid requirement, and their votes had been unequivocal. But they were pragmatists. If there was a chance that Roberts would cast the critical vote to uphold the central plank of Obamacare ― and negotiations in May were such that they still considered that a shaky proposition ― they were willing to meet him partway. When Ginsburg found out about Roberts’ new position, her first thought was, “It ain’t over till it’s over.” She understood that the process could continue to be fluid, especially in such a monumental case.

The Medicaid portion of the ruling turned out to be a lot more important than many people realized at the time, because states with Republicans in charge largely refused to expand their programs.

That has changed over time, as even many GOP-controlled states have joined the expansion ― either because governors and state lawmakers decided to embrace it or because voters approved expansion via ballot initiatives. But even today, roughly one-third of the states still have not expanded their programs.

That includes three large states in the South ― Florida, Georgia, and Texas. If every state were fully participating in the expansion, as the Affordable Care Act’s architects originally envisioned, roughly 2.5 million more people could have health insurance today.

Jonathan Cohn contributed.

Read the full excerpt from The Chief at CNN.