Iranian President Hassan Rouhani. (Ebrahim Noroozi/Associated Press)

Boris Johnson is Britain’s foreign secretary.

Wherever you look in the Middle East, America and Britain are working hand-in-glove to resolve one burning crisis after another. It may sound improbable, but things could be worse.

Suppose that on top of carnage in Syria, civil war in Yemen and the ravages of ISIS in Iraq, we were also facing an Iran on the threshold of a nuclear weapon?

Imagine if Iran’s leaders were only months or even weeks away from laying their hands on enough weapons-grade uranium for a nuclear bomb?

The truth is that without the nuclear deal, signed two years ago Friday, this scenario would have come about, adding yet another crisis to the bursting budget of crises in the Middle East.

So far, the deal — officially known as the Joint Comprehensive Plan of Action (JCPOA) — is working, and we believe it represents the best option for the international community.

Before the agreement, Iran’s underground nuclear facilities contained almost 20,000 centrifuges and more than eight tons of low-enriched uranium.

If you run that stockpile through all those centrifuges, you can “break out” and make enough weapons-grade uranium for one nuclear bomb in a few months.

Iran was steadily acquiring more centrifuges, so the situation was actually more dangerous; if nothing had been done, the breakout time would have fallen to a matter of weeks.

Thankfully, under the JCPOA, Iran gave up two-thirds of its centrifuges and 95 percent of its uranium stockpile.

Today, Iran is not weeks but at least a year away from having enough weapons-grade uranium for one bomb.

And because the nuclear agreement gives sweeping new powers to international inspectors — indeed the most intrusive monitoring applied to any country in the world — we would have a far better chance of spotting any Iranian attempt to go for a bomb.

The inspections confirm that, so far, Iran is keeping its side of the bargain. Extending the breakout period to at least a year allows us time to react to any breach of the deal.

And Britain’s view is that enforcing the JCPOA binds Iran’s hands far more tightly than it does ours.

What would happen if the agreement collapsed? The truth is that Iran — not the United States or Britain — would regain the most freedom of action. Without the constraints on their nuclear program, Iran’s leaders could bring back the centrifuges and rebuild the uranium stockpile.

The outcome would almost certainly be an Iran that strives to restore its capacity as a nuclear threshold state while continuing to threaten Israel and sponsor allies across the Middle East.

What options would the United States and Britain gain? In theory, we could reassess sanctions, but in the meantime we would face all the perils of Iran rebuilding its nuclear program — and cutting that breakout time to months or weeks.

True enough, the nuclear agreement was never intended to resolve all our problems with Iran. In one stricken country after another, Iran’s interventions are causing conflict, whether in Syria or Yemen.

I share America’s strength of feeling over Iran’s disruptive role in the region. You can be sure that Britain stands alongside the United States in resisting Iranian interference.

President Trump is right to insist on rigorous enforcement of the JCPOA; Britain continues to be robust in its defense of these terms.

Yes, Iran has benefited from a partial lifting of sanctions, but there is no evidence that the JCPOA has provided a windfall for Iran’s campaigns across the region.

Is there a danger of Iran copying North Korea and building an illicit nuclear arsenal? As it happens, North Korea’s first bombs were made not from uranium but weapons-grade plutonium — and, sure enough, Iran built a plutonium reactor at a place called Arak.

But there the comparison ends. Under the JCPOA, Iran removed the core of that reactor and poured liquid concrete over what remained, rendering Arak permanently incapable of producing anything dangerous.

In the troubled landscape of the Middle East, success is measured by the crises we avoid. The JCPOA has neutralized the supreme danger of a nuclear-armed Iran for at least a decade. That’s one less threat to worry about.