By Sadeq Saba
BBC Iran analyst
The recent rebuke by Iran's supreme leader to Mahmoud Ahmadinejad may indicate that the clerical establishment is beginning to lose patience with a president whose popularity has been plummeting in recent months amid a worsening economic situation.
There is a growing gap between president and supreme leader
Ayatollah Ali Khamenei publicly intervened on Monday to end a dispute between Mr Ahmadinejad and parliament by ordering the president to implement a gas-sector law.
This kind of intervention by the supreme leader is rare in Iranian politics.
The ayatollah could have opted for a private resolution of the dispute.
The fact that he decided to go public and send a letter to parliament to overrule Mr Ahmadinejad may suggest that he wants to convey a signal that he is not happy with the president.
Ayatollah Khamenei's previously effusive and often unconditional praise for Mr Ahmadinejad angered many people in the clerical establishment, who believe the president's domestic and foreign policies have harmed the interests of the Islamic Republic.
Ironically, Mr Ahmadinejad's position inside the country has become more precarious since the publication of a US intelligence report in December suggesting that Iran was no longer pursuing a nuclear weapons programme.
That report took some of the heat out of Iran's nuclear dispute with the West, and Mr Ahmadinejad consequently lost one of his strongest cards to mobilise his supporters and to overshadow his internal problems.
In Iran's multi-layered and complicated political structure, the president is not the most powerful man.
That status is reserved for the supreme leader, currently Ayatollah Ali Khamenei.
But the president is certainly responsible for managing the economy. And the economy has proved to be Mr Ahmadinejad's Achilles heel.
During his presidential campaign, he hardly ever mentioned the ambition to make Iran a nuclear power or "annihilate" Israel.
His main slogans were about bringing "the oil wealth to every family's dinner table", fighting corruption and reducing rising inflation and chronic unemployment.
This was essentially his appeal to Iran's poor, the constituency that elected him.
But after two years in power and record revenues from oil, the economy is in deeper crisis and the poor are bearing the brunt of Mr Ahmadinejad's economic policies.
These failures and the danger of popular revolt have caused serious concern among conservative clerics.
He has recently been facing hostile crowds in universities, and industrial action by teachers, bus drivers and factory workers has been on the rise.
Mr Ahmadinejad's style of government has also created many enemies.
His massive purging of the Iranian bureaucracy, installing a close-knit group of allies in key positions, labelling political rivals as traitors and spies, and his revolutionary rhetoric have caused alarm among the clerical establishment and many now see him as a liability.
His government has been labelled as a "barracks regime" by his reformist rivals because a majority of his senior officials come from the ranks of the Revolutionary Guard.
Many believe Mr Ahmadinejad is even using the nuclear issue to bolster his personal power
There is no doubt that without Ayatollah Khamenei's direct support, Mr Ahmadinejad would probably not have been elected as president.
There has been a public dispute over winter fuelling
But the supreme leader must now feel that he got more than he bargained for.
Over the past few months, he gave the green light to some newspapers and people close to him to criticise the president.
But his recent public humiliation of Mr Ahmadinejad over the dispute with parliament seem to be the beginning of a new chapter in his relations with him.
This new situation may have serious implications for Mr Ahmadinejad's re-election as president in 2009.
If the economy does not improve, leading to a further fall in Mr Ahmadinejad's popularity, and international sanctions over Iran's nuclear programme continue, the ruling clerics may decide to ultimately sacrifice him to preserve the Islamic system of government in Iran.
But Mr Ahmadinejad is a fighter and it does not appear that he will back down.