|Ayatollah Ali Khamenei's hold on power appears to be under threat [AFP]
Since Mahmoud Ahmadinejad was declared runaway winner of the presidential election last week, Iran has seen a daily wave of opposition demonstrations, police crackdowns and violence.
Not since the 1979 Islamic Revolution when Ayatollah Ruhollah Khomeini overthrew the shah has Iranian society been so rattled and divided.
According to the Iranian constitution, the Guardians of the Constitution are supposed to monitor and sign off on election results.
After the votes have been counted and the winner announced by the interior ministry, the Guardians have the responsibility to endorse the result within 10 days if there are no complaints from the defeated candidates.
The president-elect is then confirmed and later sworn in by Iran's supreme leader, Ayatollah Ali Khamenei.
But last week's election did not follow these procedures.
Despite complaints by Mir Hossein Mousavi, Mehdi Karroubi and Mohsen Rezaei, the opposition candidates, Ayatollah Khamaenei congratulated Ahmadinejad in a public speech and pointed out that he had got 14 million votes more than the first time he was elected president four years ago.
The pronouncement, together with a self-congratulatory victory rally in which Ahmadinejad branded the supporters of the defeated candidates as "floating bushes", infuriated opposition supporters and they took to the streets in Tehran and other major cities.
|Mousavi and his supporters say the election was rigged [AFP]
The establishment backed by militias and special forces beat demonstrators and arrested scores of prominent opposition figures, journalists, students and lawyers.
Khamenei maintained his silence for two days before urging the opposing sides not to anger each other by making explosive comments at a private meeting of the candidates' representatives.
He asked the opposition candidates to lodge their complaints to the Guardians of the Constitution for consideration - an indirect admission that the correct procedure had not been followed following the election.
The Guardians of the Constitution later announced they would consider the complaints and admitted a partial recount of the election results may be necessary.
Observers believe the moves by the conservative Guardians of the Constitution, who are known to support Ahmadinejad, were just to calm down anti-government supporters.
Still, they have promised to meet all the defeated presidential candidates on June 20 and take all their complaints into consideration.
Many moderate clerics, some of whom are believed to be members of the powerful Assembly of Experts, have questioned the wisdom of Khamenei in hastily endorsing Ahmadinejad's "victory".
The Assembly, which selects the country's supreme leader, is chaired by Ayatollah Hashemi Rafsanjani who is considered by many as one of the pillars of the Islamic Revolution.
He was the man behind the election of Khamenei as supreme leader soon after the death of Ayatollah Ruhollah Khomeni in 1989.
In theory at least, the Assembly has the constitutional right to question and even replace the supreme leader.
Some influential moderate clerics privately admit that Khamenei has not done "justice" to the presidential candidates and has not treated them with impartiality.
|Khamenei and Rafsanjani appear to be locked in a power struggle for influence in Iran [AP]
This behaviour, they believe, could jeopardise his position as leader since one of the main qualities required of the supreme leader is "justice".
Rafsanjani is also the chairman of the Expediency Council which is a body charged with the power to resolve differences or conflicts between parliament and the Guardians of the Constitution, but its true power lies more in its power to oversee the supreme leader.
It is a well-known fact that there is a lot of bad blood between Ahmadinejad and Rafsanjani whom the president accuses of corruption and aristocratic behaviour.
Ahmadinejad angered Rafsanjani when in his presidential television debate with Mousavi, he alleged that all the three opposition candidates had been put forward by Rafsanjani to defeat him.
He further accused Rafsanjani of unlawfully accumulating massive wealth over many years and putting his cronies in the way of the president.
The allegations prompted Rafsanjani to write a highly critical open letter to Khamenei, which the supreme leader ignored.
The result has been serious public rift within the establishment and many observers believe Rafsanjani may be encouraging the ferment among supporters of the opposition presidential candidates.
Mohammed Khatami, the former Iranian reformist president, has also been serving in the ranks of the "green movement" of Mousavi, who together with fellow candidate Karroubi, have been calling for the annulment of the election which they believe was rigged by Ahmadinejad supporters.
All this leaves Khamenei in a very difficult situation.
He is unlikely to either accuse the opposition supporters of being mercenaries of "foreign powers" as Ahmadinejad supporters have done.
Nor is he likely to agree to their demand that the election result be cancelled or to have an impartial election fact-finding body set up.
Instead, Khamenei, who is to give a sermon after Friday prayers at Tehran University, is likely to invite both sides to unite and accept the results of the votes or risk jeopardising the Islamic revolution and state.
But Mousavi and his supporters are just as unlikely to stop their protests until they have achieved their goal.
The deep frustration and disillusionment of the mainly urban supporters of Mousavi, together with the establishment rifts now out in the open, are posing a serious threat to Khamenei's authority.
That may benefit Rafsanjani, who aspires to become the next supreme leader, and rumours abound that he is trying to muster support among some influential clerical members of the Assembly of Experts to take Khamenei to task.
This may prove difficult, however, considering that there is still the well-armed and powerful Iranian Revolutionary Guard – that some say are the country's de facto rulers - to contend with.
Farzad Agah is an Iranian journalist and analyst living in London. The views expressed by the author are not necessarily those of Al Jazeera.