It seems likely the elections were rigged or tampered with given the results:
BBC NEWS | Middle East | Q&A: Iran election aftermath
Particularly interesting is the rural-urban divide. All of a sudden, Ahmadinejad won in urban areas from where he has traditionally drawn little support.
The election was never really democratic since the Council of Guardians and the Ayatollah closely monitor and screens all candidates to all posts. For example, in the 2001 Presidential election, 800 applications for the Presidential election were made of which 10 people were allowed to run.
Having said that, the protests are so fascinating. Even if the elections are restricted to a few candidates deemed likely and the religious establishment monitors everything closely, the Ayatollah's favored candidate won, victory was declared quickly but is scarcely accepted by all segments of the Iranian population. The ayatollah's favored candidate and incumbent is being protested by hundreds of thousands (potentially millions) of people on the streets and in universities. These protests seem spontaneous in some areas and organized in others. The opposition candidate whose supporters are leading the protests is the reform candidate, far more moderate towards the West.
BBC NEWS | Middle East | Iran's presidential candidates
What do the protests mean for Iran's future --
Is democratization inevitable?
A less harsh dictatorship?
A narrower, harsher dictatorship will emerge in response to dissent?