Ayatollah Khamenei, whose priority is domestic stability, was becoming worried about severe damage spat with his president was causing and wanted to put an end to it, says analyst.
Iran's supreme leader Khamenei ends row with President Ahmadinejad
Iran's supreme leader, Ayatollah Ali Khamenei, backed president Mahmoud Ahmadinejad's government yesterday and called for an end to a prolonged dispute between rival factions within the ruling conservative camp.
The cleric's intervention came after a crescendo of criticism in recent days against the president from influential hardliners, many of them in parliament.
They accuse Mr Ahmadinejad of trying to monopolise power and of being literally spellbound by a "deviant current" in his entourage that they claim poses a grave threat to the Islamic regime.
Ayatollah Khamenei was widely regarded to have given tacit approval to the president's opponents to attack him, hoping to rein in his one-time protege.
Mr Ahmadinejad had crossed a red line in recent weeks by challenging the ayatollah's authority over cabinet appointments.
However, said Meir Javedanfar, an Iranian-born analyst based in Israel, "Khamenei was becoming worried about the severe damage the spat was causing. He wants to put an end to it. His priority is domestic stability and cohesion within the hierarchy of the regime."
The crisis has unfolded as Iran's economy is under increased pressure from fresh US and European sanctions over its nuclear programme, and while its main ally, Syria, is facing a battle for survival from mass anti-government protests.
In an address to parliament, Ayatollah Khamenei said: "While there is weakness and problems, the composition of the executive branch is good and appropriate, and the government is working. The government and parliament must help each other."
At the same time, he cautioned his often recalcitrant president: "When a law is passed, the government must implement it with full power and without any excuse." Parliament has on several occasions criticised Mr Ahmadinejad for making decisions without consultation.
The supreme leader will now hope that Mr Ahmadinejad has been sufficiently chastened and will bow to his will in the future.
Most analysts expressed doubt that the power struggle will soon end, viewing Mr Ahmadinejad, a populist and pugnacious politician, as being far too ambitious to serve out his last two years in office as a lame-duck president.
"We may see a lull. The battle is over but the war is not," Mr Javedanfar said.
Other analysts said Ayatollah Khamenei made his truce call now because he does not feel the time is ripe to attempt to remove Mr Ahmadinejad, whose disputed re-election in 2009 he hailed as a "divine assessment".
A senior analyst in Tehran said: "The Revolutionary Guards, traditionalist politicians and hardline clerics are on Khamenei's side, but this is not enough for him to make a radical move like ousting Ahmadinejad.
"He is wary of Ahmadinejad's influence and also knows that if the boat sinks, they'll go down together."
The analyst argued that the septuagenarian supreme leader has made a typically astute move, appearing to be a "benevolent and impartial godfather", while relying on Mr Ahmadinejad to dig himself into a deeper hole.
A leading parliamentarian, Mohammad Reza Bahonar, said on Saturday that Ayatollah Khamenei "wants the government to continue its work to the end of its term [in 2013] with serenity".
The president cannot now claim he was insufficiently supported by the supreme leader if he makes further blunders and is impeached by parliament. This threat was raised by some influential politicians in recent weeks.
If this were to happen, the analyst in Tehran predicted that "Khamenei, acting as the 'father of the nation', can step in and promote a presidential candidate more to his liking".
Under Iran's unique dual system of government, the president's powers are dwarfed by those of the supreme leader. Mr Ahmadinejad has often challenged this political ground rule.
The dispute erupted last month when the president tried to force the resignation of the powerful intelligence minister, Heydar Moslehi, a move Ayatollah Khamenei publicly vetoed.
Mr Ahmadinejad went into a defiant sulk and boycotted his official duties for nearly two weeks. Mr Bahonar said the president had considered resigning over the affair.
Instead, Mr Ahmadinejad eventually accepted that the spy chief would stay, and pledged his loyalty to the supreme leader.
Within days, however, the president set the tone for a new contest of wills with Ayatollah Khamenei by appointing himself caretaker of the vital oil ministry, a portfolio the supreme leader views as his domain.
A key test of whether Mr Ahmadinejad will now buckle to the supreme leader's wishes will be if he sacks his controversial chief of staff and in-law, Esfandiar Rahim Mashaie, as leading conservatives are demanding.
On Saturday, a key aide to the supreme leader called on Mr Ahmadinejad to "turn back to the main path" and make policy or personnel changes.
Ali Saeedi, Ayatollah Khamenei's representative to the Revolutionary Guards, also repeated accusations that some of the president's senior aides were corrupt and involved in witchcraft.