Donald Trump was repeatedly warned that his aggressive policy of escalating military and economic “maximum pressure” on Iran risked triggering war by accident. Last week, the long-predicted miscalculations duly occurred and, for a few scary hours, the world tottered on the brink. Both sides in the Gulf made mistakes, although US commanders appear more at fault. But the biggest mistake of all was made in 2016, when Americans picked a dangerous fool for president.

The sequence of events that led Trump to order airstrikes on Thursday evening, then pull back with minutes to spare, began with the shooting down by Iran of an unmanned US surveillance drone. Threats and insults had been flying back and forth for months. In the preceding week, Washington accused Tehran of attacking oil tankers – and sent more troops to squat around its borders. But it was the drone incident that brought matters to a head.

The Pentagon said the drone was flying in international airspace when hit by a missile. Iran hotly denied that, saying its sovereign airspace was being violated. The US produced maps. So, too, did Iran, which was so sure of its case that it vowed to take it to the UN security council. Yet, as the White House struggled to explain why the strikes were called off, questions emerged about its account.

The Pentagon’s images of the drone’s route initially included an incorrect description of its flight path. On Friday, US officials belatedly confirmed Iran’s assertion that a second, manned plane – a US navy P-8A Poseidon – was present during the incident, a fact they had previously failed to mention. Iran, meanwhile, published photographs of wreckage allegedly retrieved from its territorial waters.

In tweets and interviews on Friday, Trump and his backers claimed, variously, that he halted the strikes to save human life, that a local Iranian commander opened fire without authorisation, even that the on-off strikes were a cunning ploy. But a senior administration official, speaking anonymously, seems to have come closer to the truth when he said the strikes were halted due to “concerns” that the drone, or another US drone, or the navy P-8A, had indeed strayed into Iranian airspace “at some point”.

‘A senior official said the strikes were halted due to “concerns” that the drone, or another US drone, or the navy P-8A, pictured, had strayed into Iranian airspace.’ Photograph: US Navy

This degree of confusion and incompetence in US military operations should not come as a total surprise. In Afghanistan and Iraq, systemic blunders, notably by the US airforce, have cost thousands of civilian lives, as UN figures show. The US record in the Gulf is little better. In 1988, a US navy missile cruiser shot down an Iranian passenger jet, killing 290 people. The Pentagon initially denied responsibility, then claimed the plane posed a threat. In 1996, the US finally paid compensation.

What is more surprising, even shocking, is how chaotic was last week’s Oval Office decision-making process. Why on earth was Trump not informed earlier of the likely death toll? (Perhaps he was.) What did his hawkish advisers think the strikes would achieve? How did Trump plan to respond to inevitable Iranian retaliation against US and allied forces in the Gulf or in the Iraq, Syria-Israel or Saudi-Yemen theatres? Is it really true that a Fox News host, reportedly a presidential confidant, persuaded Trump to press pause?

This Carry On up the White House would be comical if it were not so deadly serious. The latest episode of Trump buffoonery was a desperately unfunny near-miss for the Middle East and global stability. It underscores the urgent need for a return to honest diplomacy, and the reaffirmation of the 2015 nuclear deal with Iran. It is a wake-up call for Congress, which must accelerate current efforts to curb presidential war-making powers. And it shines new light on Trump’s unique unfitness for office.

Trump says he doesn’t want a war. The way he is behaving, war may become unavoidable.