One of the great hypotheticals of Barack Obama’s presidency involves the Iranian uprising that began on June 12, 2009, after Mahmoud Ahmadinejad was announced the winner of contested presidential elections. What if the president had done more to help the protesters when the regime appeared to be teetering?

It’s well-known he was slow to react. Obama publicly downplayed the prospect of real change at first, saying the candidates whom hundreds of thousands of Iranians were risking their lives to support did not represent fundamental change. When he finally did speak out, he couldn’t bring himself to say the election was stolen: “The world is watching and inspired by their participation, regardless of what the ultimate outcome of the election was.”

But Obama wasn’t just reluctant to show solidarity in 2009, he feared the demonstrations would sabotage his secret outreach to Iran. In his new book, “The Iran Wars,” Wall Street Journal reporter Jay Solomon uncovers new details on how far Obama went to avoid helping Iran’s “Green Movement.” Behind the scenes, Obama overruled advisers who wanted to do what America had done at similar transitions from dictatorship to democracy, and signal America’s support.

Solomon reports that Obama ordered the CIA to sever contacts it had with the movement’s supporters. “The agency has contingency plans for supporting democratic uprisings anywhere in the world. This includes providing dissidents with communications, money and in extreme cases even arms,” Solomon writes. “But in this case the White House ordered it to stand down.”

At the time, Solomon reports, Obama’s aides received mixed messages. Members of the Iranian diaspora wanted him to support the uprisings. Dissident Iranians from inside the country said such support would be the kiss of death. In the end, Obama did nothing, and Iran’s supreme leader blamed him anyway for fomenting the revolt.

It’s worth contrasting Obama’s response with how the U.S. has reacted to other democratic uprisings. The State Department, for example, ran a program in 2000 through the U.S. Embassy in Hungary to train Serbian activists in nonviolent resistance against their dictator, Slobodan Milosevic. Milosevic, too, accused his opposition of being pawns of the U.S. But in the end his people forced the dictator from power.

Similarly, when Georgian President Eduard Shevardnadze met with popular protests in 2003 after rigged elections, George W. Bush dispatched James Baker to urge him to step down peacefully, which he did. Even the Obama administration provided diplomatic and moral support for popular uprisings in Egypt in 2011 and Ukraine in 2014.

Iran though was different. Obama from the beginning tried to turn the country’s ruling clerics from foes to friends. It was an obsession. And even though the president would impose severe sanctions on the country’s economy at the end of his first term and beginning of his second, from the start Obama made it clear the U.S. did not seek regime change for Iran.

It’s debatable whether the U.S. ever did support such a policy. But it’s striking the lengths to which Obama went to make good on his word. As Solomon reports, Obama ended U.S. programs to document Iranian human rights abuses. He wrote personal letters to Iranian Supreme Leader Ayatollah Ali Khamenei assuring him the U.S. was not trying to overthrow him. Obama repeatedly stressed his respect for the regime in his statements marking Iran’s annual Nowruz celebration.

His quest to engage the mullahs seems to have influenced Obama’s decision-making on other issues, too. When he walked away from his red line against Syria’s use of chemical weapons in 2013, Solomon reports, both U.S. and Iranian officials had told him that nuclear negotiations would be halted if he intervened against Bashar Assad.

Obama eventually did get a nuclear deal with Iran. Solomon’s book shines in reporting the details of the diplomacy that led to the 2015 accord. American diplomats held two sets of negotiations with Iran — one public channel with the British, Chinese, European Union, French, Germans, Russians and the United Nations — and another, bilateral track established through the Sultanate of Oman. In 2013, U.S. officials shuttled on public buses between two hotels in Geneva to conduct the two tracks before telling their negotiating partners about the formerly secret channel to Iran.

Eventually, the Iranians wore down the U.S. delegation. At the beginning of the talks in 2013, the U.S. position was for Iran to dismantle much of its nuclear infrastructure. By the end of the talks in 2015, Secretary of State John Kerry and his team “agreed that Iran would then be allowed to build an industrial-scale nuclear program, with hundreds of thousands of machines, after a 10-year period of restraint.”

Other U.S. red lines were demolished, too. The final deal would allow the U.N. ban on Iranian missile development to phase out after eight years, and the arms embargo against Iran to expire after five. Iran would not have to acknowledge that it had tried to develop a nuclear weapon, even though samples the Iranians collected at its Parchin facility found evidence of man-made uranium.

In one particularly revealing passage, Solomon captures the thinking of Kerry, who engaged in detailed negotiations over the deal in the final months of the talks. “So many wars have been fought over misunderstandings, misinterpretations, lack of effective diplomacy,” Kerry told Solomon in a 2016 interview. “War is the failure of diplomacy.”

Kerry’s diplomacy succeeded. But the Middle East got war nonetheless. “The Revolutionary Guard continues to develop increasingly sophisticated weapons systems, including ballistic missiles inscribed with threats against Israel on their nose cones,” Solomon writes in the book’s concluding chapter. “Khamenei and other revolutionary leaders, meanwhile, fine-tune their rhetorical attacks against the United States, seeming to need the American threat to justify their existence.”

There was a chance for a better outcome. There is no guarantee that an Obama intervention would have been able to topple Khamenei back in 2009, when his people flooded the streets to protest an election the American president wouldn’t say was stolen. But it was worth a try. Imagine if that uprising had succeeded. Perhaps then a nuclear deal could have brought about a real peace. Instead, Obama spent his presidency misunderstanding Iran’s dictator, assuring the supreme leader America wouldn’t aid his citizens when they tried to change the regime that oppresses them to this day.

Eli Lake is a Bloomberg columnist who writes about politics and foreign affairs.