President Trump has told a crowd of cheering Polish nationalists in Warsaw that the great threat to the world is from “radical Islamic terrorism”, which should make it good news for him that Isis is losing Mosul, the heart of its self-proclaimed Caliphate and its de facto capital in Iraq. At the same time, US-backed Syrian-Kurdish forces are closing in on Raqqa, the last big Isis-held city in Syria, which they will capture in the coming weeks or months.

Isis has been the most powerful enemy of peace in the Middle East and beyond over the last three years, so why is its defeat in its two largest strongholds not making the region feel a safer place? Instead, the mood is edgy and fearful, bringing to mind the atmosphere in Europe in 1914 when many different conflicts were escalating and cross-infecting each other. It is not so much that the great powers are itching to fight each other in the Middle East, but, as in the period before the First World War, there are so many “wild cards”, in the sense of inputs or ingredients of uncertain value in the political mix, that almost anything could happen.

The “wild cards” are of two different kinds, though both are dangerous. One source of uncertainty revolves around deeply flawed leaders like Donald Trump himself, Crown Prince Mohammed bin Salman in Saudi Arabia and Turkish President Recep Tayyip Erdogan. All have a great appetite for power at home and abroad, combined with a reputation for arrogance and poor judgement. Ominously, all are leading players in potentially explosive confrontations and crises that could easily turn into serious wars, where they have not already done so.

The current situation in northern Iraq and eastern Syria, where Isis is on the retreat, is a good example of this. The implosion of Isis creates a vacuum leading to further conflicts over who will fill the gap left by its defeat: as regards Syria, Turkey is deeply alarmed by the rising power of the Kurds, who, backed by US-led air power, have established a de facto state along the southern Turkish frontier. Syrian Kurds, for their part, fear that the Turkish army will invade northern Syria and end their quasi-independence once the US no longer needs their 50,000 fighters to combat Isis.

Iraq PM Haider al-Abadi hails 'big victory' in Mosul

What is US policy in the struggle for eastern Syria which has drawn in their own country, Russia, Iran, Turkey, Saudi Arabia, Israel, the Syrian government, al-Qaeda, Isis, Kurds and many others? The US has already fired missiles at a Syrian government airbase and shot down a Syrian military aircraft, but otherwise nobody knows what Trump intends to do. Will he betray the Kurds once the US has no further use for them against Isis in order to get back on good terms with Turkey? Alternatively, the US could limit its role in Syria and Iraq once Isis is defeated or see both countries as the future arena for a confrontation with Iran.

“We don’t have a policy in Syria,” said one former State Department official. “Everybody in the Middle East knows that whatever is said by the Pentagon, State Department or National Security Council lacks authority because whatever assurances they give may be contradicted within the hour by a presidential tweet or by one of the factions in the White House.” The ex-official lamented that it was like living in an arbitrary and unpredictable dictatorship.

Donald Trump’s genius for spreading chaos was displayed in May during his visit to Saudi Arabia, when his fulsome endorsement of Saudi policies encouraged Riyadh to blockade Qatar and seek to turn it into a Saudi vassal state. The US President gave his support to Deputy Crown Prince Mohammed bin Salman, who has since taken over as Crown Prince, and has been the effective ruler of the Kingdom since 2015. His record since then is of undiluted failure: he backed a rebel offensive in Syria that precipitated Russian military intervention; he started bombing Yemen in a war that is still going on and is devastating the country; and he is destabilising the Gulf by trying to crush tiny Qatar.

Drone footage shows the devastation in Mosul's old city and the destroyed al-Nuri Mosque

Crises have always been erupting in the Middle East, but today there is a sense of them spinning out of control. US policy is to be redirected to supporting its own interests, comically supposing that it was previously a model of altruism and self-denial.

Under Trump, the US is to focus more on repelling the advance of Iranian influence, something much encouraged by Israel and Saudi Arabia. But the US needs a degree of cooperation with Iran if there is to be a de-escalation of the violence in Iraq and Syria. Confrontation with Iran is a recipe for fighting the Shia community as a whole and is a guarantee of instability.

A more aggressive policy towards Iran is conceived with dangerous frivolity. Media pundits and think tank luminaries have little idea of what they are talking about, any more than they did when invading Iraq in 2003. They speak of the US supporting guerrilla war by ethnic minorities against the central government in Iran, a tactic that is likely to get a lot of people killed but without worrying the authorities in Tehran too much.

US military action in Iraq and Syria is largely continuing so far along the same lines as under President Obama, because nobody in the Trump administration knows what to put in its place. It has become more militarised with officers in the field deciding on what and when to bomb. The US-directed bombardment of Mosul has become noticeably more devastating under Trump than it was under Obama last year.

Children of Mosul describe life under Islamic State

The analogy between the Middle East today and Europe in the years leading up to 1914 is illumination. There are strong parallels between Trump and Kaiser Wilhelm II, or “Kaiser Bill” as he was known derisively in Britain, in the way in which both men have stumbled into situations they did not understand. Both were the egocentric and ill-informed advocates of a bombastic nationalism in which they portrayed themselves as defending their nations – America or Germany – against the plots and self-aggrandising policies of foreign states. In 1896, the Kaiser suddenly shot off a notorious telegram offering support to the Boers against a British intrusion, much as Trump was to tweet his support for Saudi Arabia against Qatar over a century later.

Trump and the Kaiser behaved with the same blend of hubris and self-pity, seeing themselves and their nations as eternal victims, often blaming the media for malign misrepresentation. In 1908, the Daily Telegraph published a notorious interview with the Kaiser in which he made various offensive remarks about the English, whose suspicions of himself are “quite unworthy of a great nation”. He concludes with a very Trump-like bleat in which he insisted that “I am the friend of England, and your press – at least a considerable section of it – bids the people of England refuse my proffered hand and insists that the other holds a dagger.”