'They have elected a ­Labour government," a Savoy diner famously declared on the night of Britain's election landslide in 1945. "The country will never stand for it." From the evidence so far coming out of Iran, something similar seems to be ­happening on the streets of Tehran – and in the western capitals just as desperate to see the back of Iranian president ­Mahmoud Ahmadinejad.

Of course the movement behind opposition candidate Mir Hossein Mousavi spreads far beyond the capital's elite, as did the supporters of Winston Churchill against Clement Attlee. In Iran, it includes large sections of the middle class, students and the secular. But a similar misreading of their own social circles for the country at large appears to have convinced the opposition's supporters that it can only have lost last Friday's election through fraud.

That is also reflected in the western media, whose cameras focus so lovingly on Tehran's gilded youth and for whom Ahmadinejad is nothing but a Holocaust-denying fanatic. The other Ahmadinejad, who is seen to stand up for the country's independence, expose elite corruption on TV and use Iran's oil wealth to boost the incomes of the poor majority, is largely invisible abroad.

While Mousavi promised market reforms and privatisation, more personal freedom and better relations with the west, the president increased pensions and public sector wages and handed out cheap loans. So it's hardly surprising that Ahmadinejad should have a solid base among the working class, the religious, small town and rural poor – or that he might have achieved a similar majority to that of his first election in 2005. That's what one of the few genuinely independent polls (the US-based Ballen-Doherty survey) predicted last month, when the Times reported Ahmadinejad was "expected to win".

But such details have got lost as the pressure has built in Tehran for a "green revolution" amid unsubstantiated claims that the election was stolen. The strongest evidence appears to be some surprising regional results and the speed of the official announcement, triggered by Mousavi's declaration that he was the winner before the polls closed. But most official figures don't look so ­implausible – Mousavi won Tehran, for instance, by 2.2m votes to 1.8m – and it's hard to believe that rigging alone could account for the 11 million-vote gap between the main contenders.

If Ahmadinejad was in fact the winner, then there is an attempted coup going on in Tehran right now, and it is being led by Mousavi and his western-backed supporters. But for the demonstrators facing repression in Tehran, the conviction that they have been cheated has created its own momentum in what is now a highly polarised society. That is given more force by the fact that the protests are underpinned by a split in the theocratic regime, of which Mousavi and his allies are a powerful component.

Part of that is about a perceived threat to their own economic interests. But the division also reflects differences within the establishment about how to respond to Barack Obama and the overtures from Washington. All factions uphold Iran's right to continue nuclear reprocessing, but Mousavi's campaign was critical of the level of support given to Hezbollah and Hamas, while Ahmadinejad's supporters argue that only toughness can win western acceptance of Iran's status as a new regional power.

Iran is of course at the centre of an arc of crisis across the greater Middle East, from Palestine to Pakistan: the legacy of the Bush administration's catastrophic failure in Iraq and the wider war on terror. And as the US attempts to reconstitute its hegemony in the region on a new basis – for which Obama's speech to the Muslim world in Cairo was supposed to set the tone – there's reason to believe that the birth pangs of the new order may yet turn out to be as painful as the death throes of the old.

Last Friday, even before the polls had closed in Iran, the US president ­commented that people were ­"looking at new possibilities" in Iran, just as they had in Lebanon's elections the previous weekend. In fact, the unexpected defeat of Hezbollah's opposition coalition (which nevertheless won the largest number of votes) seems to have had more to do with local Lebanese sectarian issues and large-scale vote buying than the Obama effect. But the implications of his remarks were not lost in Iran, where the US is still spending hundreds of millions of dollars in covert destabilisation programmes.

Obama's public engagement over the Israel-Palestine conflict has so far elicited a commitment by Israel's Benjamin Netanyahu to the paper ­principle of a Palestinian state – backed by both his predecessors and George Bush and hedged around with so many restrictions it would barely merit Ruritanian status – but no climbdown over illegal settlement expansion. The chances of a negotiated deal in such conditions seem minimal, particularly in the absence of Hamas, and the prospects that a US plan for a settlement might then fail and plunge the region back into conflict relatively high.

Meanwhile, ­resistance and wider violence have been growing again in Iraq, as US occupation troops pull back from the cities. And in Afghanistan, far from ­winding down the occupation, Obama is ­escalating the conflict as promised, with another 21,000 US troops being sent this ­summer to fight the ­unwinnable war, as attacks on Nato forces have reached an all-time peak. At the same time, the spread of the Afghan war into ­neighbouring Pakistan has left thousands of civilians dead, created more than two million refugees and led to a civilian carnage from US drone attacks across the northwest of the country.

In case anyone imagined such wars of western occupation would become a thing of the past in the wake of the ­discredited Bush administration, ­General Dannatt, head of the ­British army, recently set out to disabuse them. Echoing US defence secretary Robert Gates, he insisted: "Iraq and ­Afghanistan are not aberrations – they are signposts for the future".

In such a context, the neutralisation of Iran as an independent regional power would be a huge prize for the US – defanging recalcitrants from Baghdad to Beirut – and a route out of the strategic impasse created by the invasion of Iraq. But so far, the signs from Tehran are still that that's unlikely to be achieved by a colour-coded revolution.