The political upheaval in Iran has caught many observers by surprise. But analysts say the sharp reaction in the streets has overshadowed deep internal divides among different factions in Iran. The turmoil has boosted the stature of some of Iran's leaders. It has also diminished the stature of others - particularly the Supreme Leader, Ayatollah Ali Khamenei.

The video clips coming out of Iran of demonstrations and beatings by police are compelling. But analysts say there is another struggle, perhaps a more significant one, taking place in the corridors of power in Tehran, and its roots go back to the 2005 presidential election.

Then, the relatively unknown mayor of Tehran, Mahmoud Ahmadinejad, surprised almost everyone by beating one of the pillars of the political establishment - Ali Akbar Hashemi Rafsanjani. Then, too, there were allegations of vote fraud, but they were never seriously investigated.  

Four years later, Mr. Ahmadinejad again defied expectations by beating former Prime Minister Mir Hossein Mousavi, and more allegations of vote rigging came. This time, there were massive protests and Supreme Leader Ali Khamenei ordered a probe by the Guardian Council into the vote.

Former U.S. Undersecretary of State for Political Affairs Nicholas Burns says the Iranian government seems stunned by the reaction and unsure what to do.

"So the government and the Guardian Council is in a very difficult position," he said. "They obviously want to preserve political stability. And the government has already said that Ahmadinejad won the election. But they're responding piecemeal, day-by-day, because the strength of the opposition is so formidable."

During this year's presidential campaign, which was characterized by an unprecedented level of personal attacks, President Ahmadinejad accused Rafsanjani and his family of being corrupt backers of losing reformist candidate Mir Hossein Mousavi. The incumbent also appeared to enjoy the backing of Supreme Leader Khamenei, although he never made an outright endorsement.

Alex Vatanka, senior Middle East analyst for Jane's Information Group, says the disputes that surfaced during the campaign continue to be played out behind the scenes.

"I think the family feud is what this is really about - Ahmadinejad going on the offensive, threatening people who remain in positions of power in Iran and saying he will drag them to court and have them convicted," he said.

"They weren't going to sit there and quietly take it. And, again, it's an overestimation of his own influence and appeal and also, perhaps, an overestimation by Ahmadinejad about how influential Khamenei is," he added.

What is particularly interesting, say analysts, is Rafsanjani's public silence. He has not been heard from during the current crisis. Yet analysts say he is fiercely working behind the scenes.

The Guardian Council, which is looking at the vote, is headed by a hardliner - Ayatollah Ahmed Jannati. But two years after his election loss, Rafsanjani became chairman of the Assembly of Experts, another appointed body that under the constitution has the power to name or dismiss the Supreme Leader.

Alex Vatanka says it is extremely unlikely that the Assembly of Experts would actually remove Khamenei. It would be a highly radical move and it has never been done. But, he says, Rafsanjani can use his chairmanship of the body as leverage with the Supreme Leader to undercut the president.

"We know from a constitutional point of view that they could put pressure on Khamenei," he said. "Obviously, that all depends on how this whole affair is going to unfold in days to come. But there is an avenue where the Supreme Leader, who is appointed by the Assembly of Experts but can also be dismissed by the same entity, could feel that sort of heat coming from that direction."

Many analysts have characterized the protests as Iran's biggest crisis since the 1979 Islamic Revolution. But Nicholas Burns, who was the Bush administration's point man on Iran policy, says a collapse of Iran's theocracy is unlikely.

"I don't think that we should assume that somehow the state is going to wither away," he said. "It's a very strong state. But the reformers are strong as well. And, of course, we'll have to watch to see if the demonstrations continue, if the government continues to backpedal."

"But I think it's one of the most important moments in Iran's history since the Revolution. And certainly, you're seeing people in the streets demonstrate with a sense of real anger that this election was held under such murky circumstances," he continued.

The Guardian Council is apparently only going to scrutinize electoral results from selected districts. But Mir Hossein Mousavi has called for a fresh election.