Much of the criticism of the Iran nuclear deal has focused on the fact that it is entirely limited to the nuclear issue, which leaves Iran a free hand — and new resources — to continue policies that have angered regional and international players. There is no denying that if Iran plays its hands well and uses the next decade to build its economic and political potential, its regional influence is likely to expand, as is its capacity to do the sort of things that have angered Israel and Gulf Arab states.

The deal’s biggest critic may be Israeli Prime Minister Benjamin Netanyahu, who called it “a historic mistake.” The irony is that the urgency with which the Obama administration pursued a nuclear deal was itself a product of Israeli actions. For Netanyahu, the deal was a good example of “be careful what you wish for.”

A little reminder is helpful here. To his credit, President Barack Obama succeeded early in his first term to get international support for sanctioning Iran — one critical reason for Iran’s willingness to take the negotiations more seriously. There have been deliberate and sustained efforts to continue pressuring Iran on multiple levels, including its behavior outside the nuclear issue.

Netanyahu preferred U.S military strikes on Iran’s nuclear facilities, over Israeli ones, from the outset. His calculus was that the key fear that could drive the U.S. debate to support military strikes on Iran was the timeline of Iran’s nuclear program — not Tehran’s support for groups like Hamas and Hezbollah.

Netanyahu exaggerated the imminent nuclear threat as much as possible. Remember how many times, over the years, he cited Iran as being only six months away from a bomb? He gave the impression that Israel was prepared to take matters into its own hands by striking Iran’s nuclear facilities, even without U.S. backing. Initially, however, most analysts, including U.S. officials, believed he was simply bluffing.

There were many reasons why the United States didn’t take Netanyahu’s early threats seriously. For one, Israel’s capacity for sustained long-distance military operations remained limited. More important, even substantial U.S. strikes were seen to have the capacity only to delay Iran’s nuclear program — not stop it.

Israel would then have also had to worry about Iranian and Hezbollah retaliation, as well as eventually dealing with a nuclear Iran. The focus on Iran was also seen as partly intended to shift attention from the Israeli-Palestinian conflict, where Netanyahu faced much international pressure.

But something happened in the lead-up to the 2012 U.S. presidential elections. The Israeli pressure on the Obama administration to take action substantially increased.

At first, it was hard to know if this was merely a political play. It was no secret that Netanyahu preferred the Republican nominee for president, former Massachusetts Governor Mitt Romney. His pressure on Obama was seen to be playing into the Republicans’ hands. But there was far more to the story than politics.

The Israelis took steps in 2012 that portrayed as credible their threat to attack Iran – and inevitably drawing the United States into the fight. We don’t know much about the specifics, but reports revealed hints that the Obama administration was growing increasingly alarmed by Israel’s actions. The Netanyahu government was spending billions of dollars on a military buildup, as well as consolidating military cooperation with Azerbaijan near Iran’s northern borders.

Not until a year later were there whispered suggestions — including one from former Israeli Prime Minister Ehud Olmert — that Netanyahu had spent billions to make his threats look more credible to Washington rather than for serious military preparation.

What is clear is that the Israeli moves were taken seriously by the Obama administration, which shifted its assessment in 2012 as more high-level U.S. officials began to take the Israeli threat to attack as credible.

Even aside from the coming presidential elections in November, the prospect was seen as disastrous for Obama. He was not going to allow himself to be dragged into another messy war in the Middle East with no end in sight. Only the Iran issue had the potential to do so, even after his re-election. And Obama also understood that the war would have been even worse for Israel.

How would war have been good for Israel? The Jewish state would have been, for the first time, at war with a Persian civilization (since all Iranians would likely have unified against the enemy) that would inevitably develop nuclear weapons anyway. It would have seemed that the United States was deliberately dragged into war on behalf of Israel — undermining the Israeli-U.S. relationship. How in the world is that good for Israel?

So a nuclear deal that would avoid war — and make it less likely to result in an Iranian bomb than war — became the Obama administration’s priority. It went into full diplomatic gear and worked on multiple tracks. The administration did everything it could to make it happen before Obama left office.

Which also meant the focus of the deal had to ignore nonnuclear issues because that would have opened a Pandora’s Box by making an early agreement almost impossible. Besides, this was not merely a U.S.-Iranian negotiation but one that involved five other countries, not to mention messy American and Iranian domestic politics.

Sure, there were other incentives along the way. The rise of Islamic State, for example, created common interests. Iran had leverage for involvement in troubled areas where U.S. influence was limited: Syria and Iraq. Some may also have seen strategic leverage to be gained with two longtime U.S. allies that can be hard to influence: Israel and Saudi Arabia.

But these were benefits that came after the fact. What truly focused U.S. priorities was that Israel made it clear to the White House in 2011-12 that Washington could otherwise be dragged into a war it could not control. One that would likely have devastating effects on both the United States and Israel. Thus started Obama’s urgent search for a nuclear deal.

In clinching the deal with Iran, Obama has, above all, succeeded in averting a disastrous war that would not have prevented Tehran from acquiring nukes. And it was Netanyahu who made sure Obama thought war was on the horizon.