Here is a measure of the madness that has been the Iraq war: British forces evacuated Basra last week, at high speed at dead of night, effectively handing over control to Iranian-supporting militias including those of the Shi'ite warlord-cleric Moqtada al Sadr, whose Mehdi army helpfully ordered a six-month ceasefire to let the Brits go home. Job well done?

Meanwhile in Baghdad, joy is unconfined because America has struck a deal with Sunni insurgents in Anbar province for them to fight al Qaeda militants rather than US troops. This deal has been lubricated by large cash injections from the US taxpayer to the very militias who have been killing American soldiers in places such as Fallujah for years. Once again, our enemies' enemies are our friends.

Except that we are responsible for creating the enemy force that we are calling on our former enemies to fight. For the supreme irony of the Iraq war is that al Qaeda was a marginal presence in Iraq - all western intelligence agencies accept this - until we invaded the place in 2003 and turned it into a Mecca for Osama Bin Laden's rootless terrorists.

What an achievement. Has there ever been a war that has been so completely misconceived? That has been so witlessly counterproductive? That has consumed so many thousands of lives only to strengthen the elements most opposed to western values?

Yet this is the "mosaic" that General David Petraeus will commend today to Congress as the fruit of the recent US military "surge" in Iraq. But it's not so much a mosaic as a threadbare patchwork of opportunistic alliances designed to provide cover for the western retreat that must now come. Britain knows it, Gordon Brown knows it, President Bush knows it and, most importantly, the Islamic militias know it. This is why there has been a period of relative calm in places such as Basra and Anbar province. It is not the peace of victory but the silence of the grave, as the militias there bury their dead and position themselves for the civil war that will almost certainly follow the ultimate US withdrawal.

So, what now? Where do we go from here? After the most disastrous military adventure in modern history, do we just shrug and move on? Put it down to experience? Suck our teeth and say that, well, democracy just doesn't "take" in some cultures? Unfortunately we can not. We will pull out of Iraq, leaving a token "overwatch" force, but the consequences of this calamity will pursue us. This war could be the prelude to a much wider crisis that could undermine our way of life and our liberties.

The first obvious consequence is that Muslim extremism of the al Qaeda variety will likely increase. Bin Laden now has secure bases in Iraq and pro-western Pakistan where he is renewing his terrorist infrastructure. His agents, the Taliban, are now inflicting withering casualties on British troops in Helmand province in some of the most sustained firefights our forces have experienced since the Second World War.

We are not winning in Afghanistan, and the withdrawal from Iraq will give heart to the Afghan militias that they, too, can dislodge the Brits from their country. They defeated the Soviet empire in the 1980s, so why not us? There is no way we can win the war in Afghanistan without a massive military presence, and a casualty rate that would be unacceptable to the British electorate following Iraq.

But there's worse. Once we have left Iraq, and the country is carved up between Kurds, Sunnis and Shias, the largest part will be under the influence of Shi'ite Iran. President Ahmadinejad has been fighting a kind of proxy war there against the Americans and their Israeli allies. He has made clear his determination to sweep Israel "into the sea", which is why the wealthy Israeli lobby in Washington is urging a military strike against Iran's nuclear industry.

Iran says it needs a nuclear "deterrent" just as much as Pakistan or Israel or Britain - and, on the face of it, it is hard to argue with such reasoning. An unstable Iraq will make the risk of a nuclear exchange in the Middle East all the more likely.

President Bush is contemplating military action against Iran to prevent what he calls "nuclear holocaust" in the Middle East. But no-one outside the loopy neo- conservative institutes thinks another war is possible. It is inconceivable that Iran will back down now as its influence grows in the region for "defeating" America.

So, we have greater international terrorism, the threat of nuclear war what else will be the fallout from Iraq? Well, how about the world economy? It's looking pretty shaky at the moment, and most of the world's oil supplies come from the Middle East. This was one covert reason for the military occupation of Iraq - a quarter of the world's oil reserves lie beneath its sands. The world price of oil is stuck at an unacceptably high level of over $70 a barrel and is unlikely to fall in the near future as the reality of America's defeat in Iraq sinks in. Energy-rich countries such as Russia see an opportunity to exploit their control of scarce resources. No wonder Des Browne, the Scottish Secretary and Defence Secretary, doesn't want to lose control of Scotland's oil to a nationalist government.

So, the world will be a poorer place as well as a more dangerous one. The recent market turmoil and the credit crisis is not a direct effect of the war, but the geo-political instability created by the debacle will certainly damage international business. America was already buckling under the cost of maintaining its military empire, even before the sub-prime mortgage crash exposed the weakness of its financial infrastructure.

And this brings us to the final, and most serious, consequence of the Iraq disaster. The damage done to American military prestige by its imminent defeat will embolden anti-western movements throughout the world. American-backed regimes such as Saudi Arabia and Pakistan are likely to fall to Muslim fundamentalists. President Putin of Russia wants to restore his country's military prestige, which is why he has been sending military aircraft to buzz western defences and has targeted nuclear missiles at western cities. China may see the time as ripe to reclaim the island of Taiwan. Latin American countries may see an opportunity to get back at the "yankees" who have dominated the continent for so long.

It is all beginning to look like one of those school history exam questions: "Discuss the causes of the breakdown in the world order after the Iraq war." The only hope is a change of government in America and some groundbreaking international diplomacy from the new regime in Britain, which at least now has learned to stop digging. I hope Gordon will save the day. But I wouldn't bank on it.