By Frances Harrison
BBC News, Tehran
The Iranian election result is a major upset. Most observers did not even think Mahmoud Ahmadinejad would make it past the first round of polling a week ago.
Mahmoud Ahmadinejad has defied all predictions
Then it was thought he was neck-and-neck with his rival, former President Akbar Hashemi Rafsanjani.
Now Tehran's hardline mayor seems to have defied all forecasts, with a landslide victory putting him far ahead of the better-known Mr Rafsanjani.
Iranians have voted not so much on his ideological position - some of them have overlooked that in a way.
It was his appeal to the poor that seems to be the secret to Mr Ahmadinejad's success. Despite Iran's huge oil wealth, the country has an unemployment problem and a big gap between rich and poor.
People see a lot of consumerism, very conspicuous spending in Tehran among the elite, but they do not themselves see the results of the country's oil boom.
The vote seems to have been one against the status quo - a sign of deep economic frustration.
Mr Rafsanjani is seen as an establishment figure, a senior cleric who has always been at the top of the revolutionary elite. Instead Iranians have chosen an alternative, younger man who talks in the revolutionary slogans of redistributing the country's oil wealth, re-nationalising the assets.
But for liberals, Mr Ahmadinejad's ascent to power is worrying. It is expected he will want to reverse some of the social freedoms introduced by the reformists and take a harder line on nuclear negotiations with the West.
His victory now puts all the organs of state in the hands of the hardliners.