The start of this was in-fighting among the mullahs. The election was restricted to candidates pre-approved by the regime. The President of Iran isn't as powerful as the Supreme Leader (chosen by a council of mullahs to serve for life) but has enough clout to affect which faction will be able to control the levers of government. So there was motivation for Ahmadinejad to steal the election.
Mousavi and his supporters didn't want to give up so they're demanding an investigation. This is separate from the actions of the street protestors who are angry at the mullahcracy as a whole. Mousavi is riding that tide but even if they win it won't take him where he wants to go. His history shows him as committed to theocracy as Ahmadinejad. He'd like to be a Gorbachev-style reformer, ascending to power through the process and making modest changes.
That's not going to happen now. If Mousavi becomes President it won't be by approval of the "Guardian Council", his peers in power. Instead he'd be installed by the mob or the army. Either way he'll have to adjust to his new power base and keep them happy lest he be quickly replaced. Possibly he's already converted to a belief in democracy. George Washington was a loyal soldier of King George in his younger days. Hopefully Mousavi will take Washington as his model . . . otherwise he may be a Necker or Kerensky.
One hopeful sign is Mousavi's tacit support for women's political power by having his wife campaigning for him and acting as his spokesman. Women in Iran are pushing back against the restrictions the theocracy has put on them. The regime strikes back at them harshly--the martyr Neda was targeted for having the loosest headscarf in the crowd--but that hasn't made them give up. Hopefully they can force the regime to crack.
I'll be praying for them.