All revolutions, I suppose, have a symbol. In Chekhov's Cherry Orchard, it's the sound of a distant chain snapping, like that of a bucket in a mineshaft. In France, it was the sans culottes. Maybe in Iran, it was the discovery an American colleague of mine made when he ventured up to the Iranian-Soviet border.

He found one of America's old listening posts still operating, with tired Iranian revolutionaries still staring listlessly at the glowing screens, tracking aircraft deep inside Soviet airspace. Why were they still manning these US bases, he asked? The problem was simple: the Iranians didn't know how to turn them off.

For me, revolutions have to have trains – Strelnikov's great steam loco in Dr Zhivago comes to mind – and Iran's huge post-revolutionary trains, 20 or 30 carriages long, windows smashed, smothered in tulip-draped posters of martyrs, would pull out of Tehran, taking me on massive journeys across the country. We drew into Qom station to find a crowd on their way to a revolutionary court, where a young officer in the Shah's army was fighting for his life, accused of killing anti-Shah demonstrators. I still remember his name – Rustomi – and his brother, in tears, pleading with me to intervene. What could I do? The crowd bayed at him, the same mob, I suppose, that would have mocked the aristocrats in Paris as they faced the guillotine.

Download the new Independent Premium app Sharing the full story, not just the headlines

There was not much mercy in the Iranian revolution: all the courts did was sentence men to death. But then there hadn't been much mercy before the revolution, when the Shah's imperial guard, the Javidan, or "immortals", slaughtered the crowds. I remember another court, in Tehran, where a man shouted at a torturer from the notorious Savak security service: "You killed my daughter. She was burned all over her flesh until she was paralysed. She was roasted." And the torturer looked back at the bereaved man and said quietly: "Your daughter hanged herself after seven months in custody."

The killers even had a few secrets for us – their close and friendly relationship, for example, with British agents and their Savak counterparts. Not unlike, I suspect, our relationship with Pakistan's state torturers (or, I suppose, with America's torturers). It was easy to hear evil. In fact, there was even a face-mask that you could buy for a few riyals, a grotesque version of the Shah's face with horns sticking out of it. The moment I put it on, a whole crowd of Iranians started shrieking at me. So I took it off.

It's easy to forget that the longest-running show in town was not the trials and their brutal aftermath – the condemned men would appear on front pages next day in their final moments – but the takeover of the US embassy by the "Students Following the Line of the Imam". It destroyed Jimmy Carter, all 444 days of it, and it is remarkable, looking back now, to see that Carter, the wise old peacemaker of the Middle East today, simply did not comprehend what had happened in Iran. How on earth did he allow the Shah into America, the catalyst for the embassy sacking? It was Henry Kissinger, of course, always the éminence grise.

The "students" spent years pasting together shredded US diplomatic traffic, incriminating past and present Iranian officials with their CIA contacts. Led by a woman, other teams worked like carpet-weavers, sewing back to life the whole rotten, corrupted empire of the King of Kings. I padded round his libraries; leather-bound volumes of Voltaire, Verlaine, Flaubert, Plutarch, Goebbels, Shakespeare, Charles de Gaulle, Churchill and Coleridge. Abba Eban's My People was dedicated by the author to "His Imperial Majesty, the Shah of Shahs".

Grandiosity became him. He staged a pitiful rodeo down in Persepolis to honour his forebears – the Pahlavi dynasty was actually introduced as a British colonial project – to which the great and the good and Princess Anne came along. I even found the Shah's bath, with its gold-plated taps, which outraged the millions of poor in a nation that Ayatollah Ruhollah Khomeini himself had described as a "slum".

And yes, of course, it was that other man we stared at, the one in the black robes whom I once, piggy-backing a US network interview, sat before. When he spoke, the Ayatollah would stare at a small emanation of light on the floor, as if it represented something holy. No Robespierre he, no Trotsky. This was a serious matter, the first Islamic revolution of our time, in which the leader proclaimed himself supreme leader and arbiter of all the revolution's cares. While he would remain the same, the revolution he created went on to become a strange creature, at once brutal and naive, provocative and dangerous. When obligingly invaded by our good friend Saddam Hussein, it sent its young men to their deaths in their tens of thousands.

A crimson tide overflowed the fountain at the great cemetery of Behesht Zahra – close to where the great man himself now lies – and we would later watch corpses coming back by the hundred. I think the eight-year war between Iran and Iraq was final proof of the revolution. Iran did not, as the US hoped, fall to pieces, but it entered a kind of stasis, a sort of childishness from which it never awoke. The French word infantilism may be closest. It was government for and by the dead. Iran had become a necrocracy.

There were many who saw what was happening. Ayatollah Taleghani, for instance, was highly critical of Khomeini's auto-theocracy, arguing that even socialists had suffered martyrs in the revolution, that they, too, should be embraced by the revolution's children. But it was not to be. When Mohammad Khatami, a genuinely good and civil man, tried to change the legacy of the now-dead Khomeini, he was defeated because he would not let his supporters die in the streets of Tehran. And so this week, it is his successor, the childish President Mahmoud Ahmadinejad, with his love for all things nuclear – or maybe not all, we shall see – who represents this great nation, a boy clutching power rather than a titan, prattling on at Holocaust "conferences" and making small talk with children.

The real test for Iran, of course, is how it casts itself adrift from this ghostly regime. It's not that the priests are fools – that was a mistake Carter made – but that running a modern, powerful nation takes more than a degree in Islamic jurisprudence. Foreign affairs is where the Iranian revolution has always failed. It has consistently underestimated – or overestimated – its enemies, although fortune has smiled on her. The Iranian mullahs hated both the "Black Taliban" and the wicked Saddam, and the Americans came along and destroyed both these enemies.

So did the revolution win? Up to a point. It might well have failed in the early days when Khomeini's courts feared a counter-coup, which was the reason for all the firing squads. They had not forgotten how the CIA and MI6 destroyed Mohammed Mossadeq's democratically elected government in a coup in 1953. Operation Ajax, the Americans called it (the British chose the more prosaic Operation Boot), and I met the Brit who staged it. Christopher Montague Woodhouse was a gentle Greek scholar, and a ruthless guerrilla fighter under German occupation in Greece. More than 40 years later he recalled for me his own feelings of guilt. "I've sometimes been told that I was responsible for opening the doors to the Ayatollah – for Khomeini and the others," he said. "But it's quite remarkable that a quarter of a century elapsed between Operation Boot and the fall of the Shah. In the end, it was Khomeini who came out on top – but not until years later. I suppose that some better use could have been made of the time that elapsed."

What happened next: After the flight of the Shah

After months of violent protests, the Shah fled Tehran on 16 January 1979. He ended up in the US where he received treatment for lymphatic cancer, from which he died in 1980.

His arrival in the US led to more than 50 Americans being taken hostage in the Tehran embassy. A bungled attempt by the US military to rescue them was one reason President Jimmy Carter served only one term in office.

He has since rebuilt his reputation as an international peace mediator.

Abolhassan Bani-Sadr became Iran's first elected president in 1979, but failed to maintain his authority against Ayatollah Khomeini. After 17 months he was impeached and fled to France where he still lives.

Matthew Bell