Now the mad mullahs of Iran will soon have nuclear bombs, are we all doomed? Thumbing his nose at the impotent west, President Mahmoud Ahmadinejad taunts us: "Our enemies cannot do a damn thing. We do not need you at all. But you are in need of the Iranian nation." And he is absolutely right. A frisson of panic shudders around the globe: he has already threatened to wipe Israel off the face of the Earth. Do something, someone! But what and who? And if there is nothing to be done, what then?

The International Atomic Energy Agency has failed to stop Iran restarting its nuclear programme. The matter has been referred to the UN, with a decision on any possible action in early March. But that may be yet another dismal reminder of UN incapacity. Meanwhile, the Americans are grinding out ritual bellicose statements, Donald Rumsfeld refusing to rule out air strikes. The Israelis warn that Iran will pay "a very heavy price" and Iran replies that if anyone attacks "we will give the enemy a lesson that will be remembered throughout history". Is this the way the world ends?

All this suggests that international diplomacy is not one whit wiser than it ever was. Talking to experts in the field, these appear to be a few key facts: even if the US or Israel strike down the sites where they think Iranian nuclear weapons are being built, that can only delay their development. (How good are we at finding weapons anyway?) If Iran wants weapons above all else, it can get them by around 2010. Unlike Libya, Iran may well put national pride before economic growth, ignoring any harm sanctions can do them. If the world's fourth largest producer sends oil prices through the roof, it can cause near-nuclear damage to the global economy. If this is how the west wants to play it, then Iran seems to hold some strong cards.

History sheds light, but offers few answers. The Anglo-American coup knocking over Mossadegh in 1953 to enthrone the shah was another shining example of how western crusaders for democracy prop up dictators in exchange for oil, afraid of the elections they pretend to champion. That is the paradox of the White House dream of turning Afghanistan and Iraq into "beacons of democracy" to spread their light across the Middle East. Yet - at least at first - democracy was always bound to bring mullahs and religious parties to power in Kabul and Baghdad or the Muslim Brotherhood's rise in Egypt. More theocratic parties are the price of free elections, and the west has to accept it.

American pride is easily bruised, unused to taking such humiliations as the 1979 embassy-hostage crisis that lasted 444 shaming days and the Iran-backed Beirut embassy attack that slaughtered 241 marines. On its side, Iran will never forgive the US for backing Iraq in the bloody eight-year Iran-Iraq war. So the two countries have barely attempted to speak in all these years: admirable EU attempts at peacemaking could not bridge that historic bile. Without the US at the table, a deal was impossible.

On the face of it, Iran has every reason to feel insecure. While America occupies two of Iran's neighbours and Israel's nuclear weapons point at Tehran, paranoia seems as justified as it is dangerous. Yet Iran knows its strength. The Iraq adventure has exposed the painful limits to force, and America can no longer make a credible threat of invasion: it has forfeited the power to frighten.

What's more, Iran is the true winner of that war. They only had to sit tight and smile as the west delivered on a golden plate all the influence Iran had always sought in the Middle East. The US and its allies will soon be gone from Afghanistan and Iraq, leaving Iranian-backed Shias dominant in both countries, their influence well spread across Syria, a chunk of Saudi Arabia and other countries for decades to come. Historic Iranian ambitions have been fulfilled without firing a shot while the US is reduced to fist-shaking. How foolish was that?

If Iran is determined, no one can stop it becoming a nuclear power, alongside Israel, Pakistan and India. The crazed dictator of North Korea shows the way: nuclear weapons make nations unassailable. Why on earth would Iran not want them too?

It is much odder that Britain demands them. What for? Protection against whom? John Reid has said Trident will be replaced - and now Gordon Brown has said he too would renew our nuclear weapons, despite the £20bn price tag and a lack of anyone to point them at. If we can seriously consider such expensive folly in pursuit of strutting our stuff and punching above our weight to buy a UN security council seat, we can hardly pretend outrage at Iran's ambitions.

But fantasy diplomacy is taking a grip. The pretence is that the world united can deflect Tehran: there is still a small chance that Russia's offer to strike a deal could work. But the experts expect an aggressive stand-off, with a risk of futile air attacks. Even if no blood is spilt, the west may find itself in a cold jihad with a God-driven, nuclear-armed adversary, and no solution in sight. Nothing suggests that sanctions and fiery words will make the more moderate forces in Iran overthrow their mullahs and choose westernisation: under external pressure in this clash of civilisations, history suggests they will close ranks. Meanwhile, oil-hungry nations will do dirty backdoor deals: oil tends to trump UN resolutions.

Fantasy diplomacy is ready to fight all the way to stop the mullahs getting the bomb. Reality suggests there is a difficult choice: if you cannot win, give up at once to minimise the damage. Get off the high horse and start to negotiate terms on which Iran can be allowed to enrich uranium. It amounts to turning a blind eye to their weapons potential while striking a deal that saves their face, affords them some dignity and entices them economically into becoming a more stable force.

It takes some swallowing, but what if there is no alternative? Either they have nuclear weapons and we are at cold war, or else they have nuclear weapons and we have an uneasy kind of peace. But that decision has to be made before UN sanctions ratchet up the rhetoric to no-turning-back resistance.

It may be beyond the ability of this White House to climb down, but the US should remember Aesop's fable The Sun and the Wind: when they competed to get a man's coat off, the full force of a cold blast only made him hold on to it tighter, but the warmth of the sun made him take it off by himself. So far US diplomacy over Iran echoes Louis XVIII's court: they seem to have forgotten nothing and learned nothing.