Garvan Walshe was National and International Security Policy Adviser to the Conservative Party until 2008.

For 30 years they marched back and forth across central Europe, killing, raping and pillaging through ever more runined cities and increasingly barren countryside. It began as a quarrel over rival interpretations of religion; became a struggle between Europe’s great powers, and ended when progressively smaller bands of wretched men under the commended by rough warlords ran out of patrons to invest in their battle. If the great historian C.V Wedgwood is to be believed that the war went on for so long had much to do with Cardinal Richelieu, who contrived to keep the Holy Roman Empire and Protestant powers in enough balance until 1648 for at least one side to think it was worth fighting on.

In today’s language that was a war of state failure, religious extremism and foreign intervention. Though it began being fought by something as close to regular military forces as the sixteenth century allowed, they decayed into rabbles and militias that pressed the people into their service: ate their crops, enslaved their women, conscripted their men, and forged their church bells and farm tools into weapons.

This Hell has now come to Syria and Iraq. ISIS’s distinguishing feature is hardly its fanaticism (Saudi Arabia leavens its similar barbarism with hypocrisy) or its violence (Assad’s security forces have killed and tortured far more) but its single-minded focus on war. Where Al-Qaeda took foreign fighters and trained them for terrorist attack, ISIS sends them to the front line. The “Islamic State” has become a war machine with a country attached.

The web of alliances and enmities is every bit as bewildering as Europe in the 1630s. Totalitarian though it may be, ISIS serves to resist what Sunni Arab powers see as Iranian Shia expansion through Hizbullah and a Shia-dominated government in Iraq. Turkey now takes another angle, against both Iran and Assad but also Egypt – also suppressing the Muslim Brotherhood to which Erdogan is sympathetic – and Saudi Arabia.

Yemen has become the third front, with Saudi Arabia bombing Iran-backed rebels and Egypt mulling mustering troops to invade again (it last invaded Yemen in the 1960s). The position line from the ostensibly pro-Western Arab states is that they are fighting against an imperalist Tehran. The previous one: that reversing Israel’s occupation of Palestine was the key to the regional peace, has been dropped like an outdated communiqué from last year’s Politburo.

But the pro-Sunni line has run into unexpected difficulty in the United States. It has not escaped Washington’s notice that Egypt and Saudi Arabia are indifferent allies. Common interests are rather less evident than they used to be (shared values were hardly present). Saudi fanaticsm inspires Islamist terrorism in general, and funds the hard-line version of Islam the terrorists find congenial. Egypt’s counter-revolutionary regime is more repressive than Mubarak’s. Both remain important, but it is no longer self-evident that their interests should automatically carry so much weight. If values were to tip the balance, they should tip it in favour of Iran, where even though women are arrested for dancing to Pharrell’s “Happy”, they are at least allowed to drive cars and have their votes counted with a modicum of fairness.

The United States has other regional aims, the most important of which is to thwart Iran’s nuclear ambitions. Reducing, though not of course eliminating, its support for the moderate Arab states might seem a worthwhile price to pay for keeping hostile nuclear weapons out of the middle east.

Nor should Iranian intereference in Iraq, Syria and Yemen be an unmitigated strategic disaster. The Islamic Republic may appear, in Riyadh and Cairo, to be projecting power but it could just as easily turn out to have got bogged down. Hizbullah has had to be diverted to propping up Assad so that even Iranian commanders advising it can now be killed by Israel with impunity. Shia Iraqi militias are now fighting ISIS in Tikrit, amidst a hostile Sunni population. The ousted Yemeni president’s observation that governing the country is like “dancing on the heads of snakes,” should unnerve the department of the revolutionary guard responsible for relations with the Houthi rebels.

After decades in which unpleasant Sunni and Shia regimes have grown filthy rich by selling their oil, assigning much of it to fund Islamic extremism, a certain amoral cast of mind might find in a long proxy war between Sunni and Shia fanatics a use for that cash pile not very detrimental to Western interests.

I very much doubt this balance is the result of a well-designed and malevolently cynical American conspiracy to foster decades of devastation in the region. Too much turns on the detail of the nuclear deal, the extent to which intelligence cooperation with Arab allies would suffer because of rapprochement with Terhan, and on whether Iran actually is bogged down in Syria, Iraq and Yemen. But the Obama Administration’s chaotic policy process could well have done enough to bring some cheer to Cardinal Richelieu’s immortal soul.