This commentary was published in The Guardian on 09/05/2011
The unprecedented confrontation at the top of the Iranian regime began only a month ago when Khamenei, the supreme leader, intervened in a cabinet appointment by reinstating a minister who had initially resigned "under pressure from Ahmadinejad".
In reaction to the reinstatement of Heydar Moslehi, the intelligence minister at the centre of the row, Ahmadinejad apparently staged an 11-day walkout from the presidential palace and refused to chair cabinet meetings.
At first glance, Ahmadinejad's feud with the ayatollah seemed like a conventional disagreement between two leaders of one country but in Iran, where Khamenei is described as "God's representative on Earth", Ahmadinejad's opposition was extremely serious.
In fact, Ayatollah Mesbah Yazdi, a prominent cleric close to Khamenei and a supporter of Ahmadinejad in the past, said that disobeying Khamenei is equal to "apostasy from God". His remarks were echoed by several other political figures including senior officials in the powerful revolutionary guards who urged Ahmadinejad to accept Khamenei's ruling over Moslehi.
Under the Iranian constitution, the president is in charge of appointing cabinet ministers who take up ministerial duties after approval from parliament. But an unwritten law puts Khamenei above the constitution and requires all officials to comply with the supreme leader at all times without showing any opposition.
To bestow legitimacy on his unconstitutional intervention in the cabinet appointment, Khamenei's decision was supported by an overwhelming majority of Iranian MPs who signed a petition and asked Ahmadinejad to abide by the supreme leader.
This was not a particularly surprising move, since Iranian MPs are all filtered by the Guardian Council which vets all candidates before any election and is under direct control of the supreme leader.
Ahmadinejad's disobedience, on the other hand, was a surprise for many who saw the president as Khamenei's stooge whose own success in Iran's 2009 "stolen" election was secured with help from the ayatollah and his military elite, the revolutionary guards.
Mutual support between Ahmadinejad and Khamenei served a purpose for both of them in the past, and mutual enmity is serving a purpose now. Each is trying to gain some popularity with the people by distancing himself from the other. Ahmadinejad is portraying Khamenei as an obstacle to the success of his policies and Khamenei is perhaps using him as a scapegoat should the "Arab spring" start to affect Iran.
Possibly Ahmadinejad has his eyes set on a third presidential term. As the constitution stands, he is limited to two terms – which means he must step down (probably into obscurity) in 2013. However, he may be hoping to change the rules before then, especially if his supporters do well in the 2012 parliamentary elections.
The other possibility – which may be more likely – is that he has been grooming his chief of staff, Esfandiar Rahim Mashaei, to succeed him in the presidency. Mashaei's daughter, incidentally, is married to Ahmadinejad's son.
Mashaei's "liberal" views and his opposition to the greater involvement of clerics in politics have worried Khamenei and his camp who believe Mashaei and his team – often described as a "deviant current" within Ahmadinejad's inner circle – are seeking to compromise the supreme leader's power.
On Sunday, Ahmadinejad, under pressure from Khamenei's camp to accept the reinstatement of Moslehi, finally appeared in a cabinet meeting with the presence of the intelligence minister. However, this does not seem like an end to a dispute which has only begun. Khamenei's trust for Ahmadinejad will never be the same.
Recent events in Tehran have highlighted the status of an isolated president whose power is on the wane.