If Iran's government was truly behind last weekend's cruise missile and drone attack on Saudi Arabia's energy infrastructure, it has put its potential foes across the Middle East in an awkward, uncomfortable position.
Like suspected mine attacks on tanker shipping in the Gulf earlier in the year, the strike – which initially sent energy prices spiking - showed just how little those who ordered it care for the norms of international engagement, even by the standards of the restive Middle East. That's not a surprise: both Iran and its enemies, particularly Israel and increasingly Saudi Arabia, have been fighting a shadow war on and off for years. This attack, however, marked a serious escalation - particularly if US officials are correct when they say the missiles were launched from inside Iranian territory.
Perhaps predictably, President Donald Trump's response was bellicose in flavour, warning the United States was "locked and loaded" but putting the decision on whether or not it should strike firmly in Saudi Arabia's court. So far, Riyadh has shown little enthusiasm for that - it appears increasingly bogged down in a controversial, messy war in Yemen, and neither it nor Washington wants shooting in the Gulf.
Amongst those in power in Tehran, the calculations appear more mixed. Outside experts increasingly suspect hardliners believe that since Trump tore up the Iran nuclear deal, they have less to lose. Even if the United States were to launch military action, it would almost certainly only be limited. Trump has made clear his opposition to major Mideast wars, and the departure of National Security Adviser John Bolton removes the only senior US figure who backed them.
With China rising and Russia reasserting itself, the United States is now much less Mideast-focused – and also less dependent on its oil. The end of the era of Iraq-style interventions is broadly positive - not least because it had fuelled Tehran's appetite for a nuclear programme. That had itself proved to destabilise, including increasing the risk of Israeli military action, and prompted the Obama administration's focus on a nuclear deal to stop it.
That approach was dramatically ditched by Trump, who tore up Iran deal with no apparent concept of what to replace it with. Powerful forces in Tehran were already pursuing an agenda of destabilising the region with covert action. The new US approach handed them a chance for ascendancy in Iran's unending internal battle for domestic power and removed what constraints they had once felt.
Particularly over the last decade, Iran's Islamic Revolutionary Guards Corps - and particularly its foreign-facing Quds Force under Major General Quassem Soleimani - has revelled in deniable actions across the Middle East and beyond.
Those actions included supporting insurgents attacking US and British forces in Iraq, Houthi rebels in Yemen and backing Bashar al-Assad's government as it battle for control of Syria. That had fuelled some calls in Washington for the IRGC to be listed as a banned terror group - but doing so, as the Trump administration did earlier this year, seems just to have increased its appetite for action.
Iran has long had a sophisticated missile programme and has been testing drones and supplying them to regional allies such as Hezbollah for years. This attack, however, showed significant recent progress. That the missiles were reportedly able to evade Saudi air defences by flying behind them demonstrates striking sophistication.
Yemen's Houthis dispute the US claims the missiles and drones came from within Iranian territory, saying they were launched from within Yemen itself. Whatever the truth, the attack clearly represents a leap forward in both technology and the appetite to use it.
So far, damage to facilities belonging to Saudi oil firm Aramco appears limited – Saudi authorities say full production will shortly be resumed. That's unlikely to bother anyone in Tehran significantly. They may well not have been looking for a knockout blow, but have demonstrated their ability to strike the most sensitive facilities in Saudi Arabia without warning. Other potential foes, including the United Arab Emirates and Israel, will have noted that with some alarm.
Such behaviour, the United States and its allies clearly believe, must not be without consequences - and Tehran should be braced for another round of sanctions. Much of the challenge here, however, is keeping the hope of diplomacy alive, giving Iran incentives to moderate its behaviour and regain admittance to the wider international community.
That, after all, was the strategy favoured by the Obama administration - and then ripped up by Trump without any discernible alternative. In a particularly counterproductive step, the United States then moved this year to sanction even relatively moderate members of the government in Tehran, including Foreign Minister Mohammed Javad Zarif, its chief negotiator for the nuclear deal.
Without appetite for military action, boosting diplomatic efforts may be the only option – and European states, in particular, have been desperate to keep such options open. That included President Emmanuel Macron inviting Foreign Minister Zarif to the G7 summit this summer, much to the irritation of Trump and the US delegation.
Nevertheless, the US appetite for a new deal may quietly be increasing. Trump's new pick for National Security Adviser, former US chief hostage negotiator Robert O'Brien, has a very different background from the mercurial Bolton. The next US presidential election is barely a year away, and the current incumbent of the White House would rather have a reputation then for stopping wars than starting them.
A former reporter for Reuters, Peter Apps is a writer on international affairs, globalisation, conflict and other issues. He is the founder of the Project for Study of the 21st Century (PS21), a non-national, non-partisan, non-ideological think tank. Paralysed by a war-zone car smash in 2006, he also blogs about his disability and other topics.