In the old Soviet Union, things were run by an inner circle of the Party called the Nomenklatura, who occupied the key positions, and retained for themselves a high standard of living relative to the rest of the USSR. Iran seems to have its own version, consisting of the upper clergy and the senior members of the Revolutionary Guard.
This unrest follows the collapse in oil prices from 12 months ago, which reduced oil revenues used to support the standard of living of the Iranian inner circle and the thugs they use to keep the rest in line. Faced with declining revenues, they have two main choices: reduce their standards of living, or trim the size of the privileged class. Either choice is likely to be unpalatable.
Mousavi seems to have wanted to trim the size of the control apparatus, disbanding the "morality police" and loosening restrictions (and thus the expense of maintaining the kind of internal force that would be needed to maintain it).
Ahmadinejad, OTOH, is in bed with the Revolutionary Guard and the Basij (who seem to be the ones performing the "morality police" function) and has their support. It could be we are seeing a situation where the Iranian security forces may want to reduce expenses by reducing the number of "inner circle" clerics.
Apparently the mullah’s fear of Mousavi’s willingness to loosen the leash a bit on the population causing then end of their control caused them to insure that Ahmadinejad would win. Mousavi was vetted by the mullahs and is just a bit less vocal than Ahmadinejad in his dictatorial desires.
See updates...#39.