Addressing the historic agreement reached with Iran on July 14 in Vienna, President Obama said he will "veto any legislation that prevents the successful implementation" of the deal. (WhiteHouse.gov)

Three years before Tuesday’s nuclear deal with Iran, the Obama administration dispatched a pair of senior military commanders to the Middle East for a different, if equally urgent, set of negotiations. The purpose: persuading Israel to delay an imminent military strike on Iran’s nuclear facilities.

At the time, the chances for military action were considered so high that U.S. officials debated when, not whether, the bombs would fall. “We’ve admitted to each other that our clocks are turning at different rates,” Gen. Martin Dempsey, chairman of the Joint Chiefs of Staff, said after his talks with Israeli leaders in August 2012.

Now, White House officials are instead toasting a major diplomatic victory: a comprehensive agreement to severely restrict Iran’s nuclear program. In a remarkable reversal, the goal of freezing Iran’s progress toward a weapons capability was achieved not with warplanes but with handshakes.

The deal announced in Vienna closes, at least for now, the most perilous chapter in 35 years of turbulent relations with the Islamic republic. By effectively freezing Iran’s uranium stockpile for at least a decade, the accord eases tensions around a controversy that has given rise to cyberattacks, assassinations and economic sanctions, all set against a backdrop of fear over the potential for a new Middle East war.

What's next for Iran after the nuclear deal

“It’s momentous,” said Cliff Kupchan, a former State Department official and an Iran expert with the Eurasia Group. “There’s only a very remote chance for the next 10 to 15 years that Iran can acquire a nuclear weapon. The United States during that period won’t have to choose between accepting a nuclear-weapons-capable Iran and using military force against that country.”

Critics pounced on perceived flaws in the deal and vowed to fight to block its implementation. But assuming that the basic contours remain intact, the accord will effectively stop progress along two paths that could potentially give Iran a nuclear weapons capability. Both Iran’s stockpile of enriched uranium and its ability to produce plutonium from a nuclear reactor will be restricted under the agreement’s terms, in a dramatic shift from the circumstances that confronted the Obama administration before the interim nuclear deal was struck in November 2013.

If it is fully implemented, as expected, the agreement will represent a major foreign policy victory for the Obama administration, which from its first days sought to transform Washington’s relations with Iran, first through offers of diplomatic engagement and then, when those overtures were rejected, by coordinating an unprecedented international campaign of economic sanctions that crippled Iran’s economy and pressured Tehran to seek a negotiated settlement.

“Diplomacy has already been successful in freezing Iran’s nuclear progress for the first time in a decade,” said Kate Gould, chief Middle East associate for the Friends Committee on National Legislation, a nonpartisan group that advocates for the peaceful resolution of international conflicts. “Today, diplomacy has carved out a future that keeps Iran from the bomb, and keeps the United States from another catastrophic war in the Middle East.”

Although Iran denied having any interest in the bomb, its nuclear facilities have long been a potential flash point in relations with the United States, blocking progress on a host of regional issues, such as terrorism and Syria’s civil war.

Iran’s interest in nuclear technology dates to the 1970s, when the country’s pro-American shah, Mohammad Reza Pahlavi, approved plans to construct up to 23 nuclear reactors with international help. But all cooperation between Washington and Tehran was halted after the 1979 Iranian revolution that brought Ayatollah Ruhollah Khomeini to power. Iranian militants acting in Khomeini’s name seized the U.S. Embassy in Tehran and held 52 American hostages for more than 14 months, precipitating a crisis that severed diplomatic relations between the two countries.

Which “red lines” drawn during negotiations ended up in the deal

Near the end of Iran’s disastrous war with Iraq in the 1980s, Iranian officials secretly obtained blueprints from Pakistan for gas-centrifuge machines used to enrich uranium. More than a decade later, in 2002, Iranian exiles revealed the existence of a massive uranium-enrichment plant under construction near the town of Natanz. The discovery marked the beginning of a new phase of conflict in Iran’s relations with the West, as the George W. Bush administration accused Tehran of seeking to acquire a nuclear-weapons capability, while Iran insisted it was merely exercising its right to develop peaceful nuclear energy for electricity.

Over the following years, the Bush White House pushed for U.N. sanctions against Iran while also participating in multiple rounds of negotiations between Tehran and the six-nation bloc known as the P5+1 — consisting of Britain, China, France, Germany, Russia and the United States. Iran would twice agree to temporarily freeze its production of enriched uranium. But under President Mahmoud Ahmadinejad, work expanded both at Natanz and a second, secretly constructed enrichment facility called Fordow, concealed inside a mountain bunker near the city of Qom.

Meanwhile, the discovery of secret documents pointing to clandestine weapons research in Iran’s military laboratories heightened fears that the nation had begun practical testing of the components for a nuclear warhead. The CIA concluded in a 2007 report that Iran had stopped the experiments, while continuing to make the fissile material it would need if it decided to build a nuclear weapon in the future. Bush administration officials were unconvinced by a series of pronouncements by Iranian leaders denouncing nuclear weapons as contrary to Islam.

Obama came into office in 2009 vowing to end the nuclear threat and transform relations with the Islamic republic. In his first inaugural address, he signaled a new willingness to negotiate with Iran’s leaders, saying his administration would “extend a hand if you are willing to unclench your fist.” He also appealed directly to the Iranian people in a series of addresses commemorating the Nowruz holiday, urging popular support for a nuclear deal that would bring a “brighter future” for the country.

But Ayatollah Ali Khamenei, Iran’s supreme leader since the death of Khomeini, spurned Obama’s overtures as his government announced plans to build still more nuclear reactors and expand a network of uranium-enrichment plants to fuel them.

By mid-2012, many weapons experts believed Iran already possessed the technical capacity to construct a nuclear bomb, requiring only an order from the supreme leader and a few months’ work to convert its stockpile of low-enriched uranium into weapons-grade fissile material. Israeli officials, sensing a limited opportunity to weaken Iran’s nuclear capability, began openly signaling an intention to attack the country’s nuclear facilities, an act that U.S. officials feared could spark a wider Middle East war.

The Obama administration lobbied fiercely to delay an attack, while simultaneously expanding covert efforts, begun under Bush, to disrupt Iran’s nuclear progress. A computer worm known as Stuxnet damaged hundreds of Iranian centrifuges between 2009 and 2010, and five Iranian nuclear scientists were killed by unidentified assailants. The attacks prompted a series of reprisals from Iran, including attempted assassinations of Israeli and Arab diplomats and a foiled plot to kill Saudi Arabia’s ambassador to Washington.

But ultimately it was economic pressure that prodded Iran to begin serious negotiations. With heavy support from Congress and European allies, the Obama administration rallied international backing for harsh sanctions against Iran.

One key measure blocked Iran’s access to international banking networks, and others froze the country’s foreign currency assets and dried up markets for vital oil exports. By mid-2013, Iran’s foreign oil sales had been cut in half, and inflation and joblessness soared.

That summer, when Iranians went to the polls to choose a new president, they overwhelmingly elected moderate cleric Hassan Rouhani, who campaigned on a promise to improve the economy by ending the sanctions.

“It was a combination of crushing sanctions and Rouhani’s election that made serious negotiations possible,” said Robert Einhorn, who participated in negotiations with Iran as a senior State Department official under the Obama and Bill Clinton administrations.

Although some branded Obama’s early outreach to Iran as naïve, his efforts to engage Iran diplomatically were key to rallying international support for the kind of tough sanctions that ultimately forced Iran to seek relief, Einhorn said. The administration “recognized it needed leverage if it wanted real negotiations,” he said.

It will be years before the success or failure of the accord is fully clear. But by reducing the threat of an Iranian nuclear bomb, the prospect of imminent military conflict can recede, opening the door to progress on other issues, such as regional terrorism as well as the holding of American hostages, said Trita Parsi, president of the National Iranian American Council, an Iranian American grass-roots organization that has lobbied for a peaceful nuclear deal.

“This is about so much more than just the nuclear issue,” Parsi said. “It can not only transform the relationship between the U.S. and Iran away from this institutionalized enmity and toward not necessarily a partnership but a more nuanced rivalry. But it can also transform U.S. foreign policy writ large.”