Chance to avert resort to arms
Until recently the probability of a military attack on Iran's still-incomplete nuclear facilities was very high.
The notion that Iran - engaged in a struggle to be the pre-eminent power broker in the region and long a backer of destabilising extremist organisations in Iraq, Lebanon, Syria, the West Bank and elsewhere - might soon acquire its own nuclear weapons was unthinkable, not just to the West but also to many of its near neighbours.
Iran, of course, has always insisted its nuclear programme is entirely for peaceful purposes but it has not allowed any meaningful inspections and the technology it was developing belied that claim.
Stiff trade and financial sanctions have been imposed but while they have badly damaged the Iranian economy they were ineffectual in significantly slowing its nuclear development.
Israel, which Iran had vowed to wipe from the map, was particularly alarmed and made no secret of the fact that it saw a military strike as inevitable.
The agreement reached with Iran at the weekend by the UK, Russia, China, France and Germany should stave off that dreadful prospect.
Though far from perfect, it is more far-reaching than had been thought possible and provided it survives the many obstacles that it will face it could be the basis for a longer-lasting, more comprehensive deal in future.
This interim agreement is set to last six months during which negotiations will continue for a permanent treaty.
Even at this point it has achieved what decades of diplomatic wrangling had failed to do - an effective freeze on Iran's nuclear development programme.
Iran's stockpile of weapons-grade uranium will be reduced, the use of centrifuges to produce more will be forbidden and confined to producing material suitable for civilian use, and work on a reactor that could make plutonium for nuclear weapons will be sharply cut.
All this has been agreed to by Iran without relaxing some of the most crippling financial and trade sanctions that have largely paralysed its economy.
While a relatively small amount (about US$8 billion) of cash in bank accounts abroad will be released, Iran will still not be able to trade in oil and its banking system will remain cut off from the rest of the world. Any concessions on those points will have to await a final deal.
The deal at the weekend was the result of intense negotiations over some months. They followed the election of a new president, Hassan Rouhani. He was educated in Scotland and has been credited for having Iran follow a more conciliatory line recently.
But the more important figure in such decisions is the country's supreme leader, Ali Khamenei, and the crushing impact of the sanctions is likely to have been the crucial factor.
The deal could still be derailed. Israel's Prime Minister, Benjamin Netanyahu, called it a "historic mistake".
He will have strong supporters in the US Senate, who may upset the deal by imposing stronger sanctions on Iran.
For the moment, though, most see the deal as giving a welcome breathing space from military action and maybe, with luck, averting it altogether.