I haven't had time to comment much on the Iranian election outcome, but Simon Kitchen at the Arabist Network has a must-read post
on where Ahmadinejad came from. He's apparently part of a movement called Abadgaran, which sounds kind of like a Khomeinist Opus Dei, only with political ambitions and mixed with economic and political populism. One should not dismiss them as a political force out of hand, as Iran is still a more conservative country than you would think if your only impressions were from today's student movement and Pahlavi-era expats and their offspring. Which is not to say that the regime is actually popular, only that some of its pillars still have a lot of support, and for many social freedoms are not the most important issues.
This is also not to say that Ahmadinejad's victory was clean, even by Iranian rules. I haven't looked over all the evidence on that one.