On second anniversary of his re-election, critics see the power of Iran's president waning as he challenges rival hardliners and the supreme leader.
Ahmadinejad fights to stay relevant
He revels in his reputation as a supremely self-confident and optimistic leader. Yet Iran's president, Mahmoud Ahmadinejad, will be hard-pressed to find much to celebrate on today's second anniversary of his highly contentious re-election.
His reformist opponents have been ruthlessly marginalised, but he now faces a possibly even tougher challenge, this time from rival fellow hardliners.
At stake is the future direction of the Islamic republic at a time of historic change in the wider region.
So bitter is the power struggle gripping Iran's ruling conservative elite that some analysts believe Mr Ahmadinejad, 54, could be ousted before his second term expires in 2013 - unless he accepts a limited role as a lame-duck president.
He can no longer rely on the unqualified support of his one-time champion, the supreme leader, Ayatollah Ali Khamenei, whose authority he challenged in a recent, public dispute over a cabinet posting.
By doing so, Mr Ahmadinejad crossed a line: many hardliners believe that questioning the supreme leader is akin to apostasy.
The row is both political and ideological. Mr Ahmadinejad's many critics in parliament and the clergy accuse him of trying to monopolise power and of being literally spellbound by a "deviant current" in his entourage that they allege promotes a nationalist and apocalyptic form of Islam.
They claim his entourage is striving to foster a system that would render redundant the post of supreme leader and undermine the clergy's role.
"This movement is the gravest danger in the history of Shiite Islam," Mojtaba Zolnour, Mr Khamenei's deputy representative to the elite Revolutionary Guards, proclaimed this week as reported by the semi-official Mehr news agency. Experts say Mr Ahmadinejad's political fate depends on whether he now submits to the supreme leader's will or continues to try to shunt more power to his office in ways that challenge Mr Khamenei and parliament.
But the ambitious and populist president, the workaholic son of a blacksmith, is as pugnacious as he is polarising. He has made few compromises during his six, turbulent years in office; confrontation appears to be hard-wired into his DNA.
He sees himself as a historic leader determined to restore Iran to the ranks of world superpowers.
Mr Ahmadinejad also intends to slash a costly, US$100 billion (Dh367bn) subsidy system without igniting unrest, a feat none of his predecessors dared even try. It is, Mr Ahmadinejad recently boasted, "the biggest economic plan in the past 50 years".
His usefulness on this and other fronts, however, "may be nearing its end", said Alireza Nader, an Iran analyst at the Rand Corporation, a US-based think tank.
Mr Khamenei and the Revolutionary Guards "have used him to accumulate even more power", sideline the reformists, continue the nuclear programme and defy the United States", Mr Nader added in an e-mail. "But Ahmadinejad has been a divisive figure" and the system is determined to prevent him being succeeded by another like-minded and unruly figure.
Iran's hardliners are jockeying for position ahead of next year's parliamentary elections and a presidential vote in 2013. Mr Ahmadinejad has made little secret of his desire to carve out a political future for himself beyond the constitutionally mandated end of his second term.
Key to his strategy is installing his highly controversial chief-of-staff and closest ally, Esfandiar Rahim Mashaie, as his successor. This, Mr Ahmadinejad hopes, will enable him to make a Vladimir Putin-style comeback in 2017.
Mr Mashaie is despised by the president's hardline opponents who insist Mr Ahmadinejad must sack him. They accuse Mr Mashaie of "bewitching" the president and of leading a "perverted", anticlerical current in Mr Ahmadinejad's camp.
The president's fall from hardline grace has been swift and spectacular. Tehran's often fractious ruling conservatives rallied behind him two years ago when, in a potent foretaste of the uprisings now convulsing the Middle East, millions of pro-democracy Iranians took to the streets to protest against what they insisted was a rigged ballot.Mr Khamenei risked his prestige as a supposedly neutral arbiter by hailing the president's purported election victory a "divine assessment".
He accused those who maintained the election was fraudulent of being Western-backed "seditionists", while the president himself infamously
dismissed the pro-democracy protesters as "dirt and dust".
Mr Ahmadinejad, apparently overestimating his popularity, has since failed to heed a basic lesson. Specifically, that the Iranian constitution subjugates the powers of the president to those of the unelected supreme leader. Both of Mr Ahmadinejad's predecessors, the centrist Akbar Hashemi Rafsanjani, and reformist Mohammad Khatami, were marginalised after their terms expired.
"All the evidence, historically, is that presidents never win," Michael Axworthy, an Iran expert at Exeter University in England, said in a telephone interview.
The game changer came in late April when Mr Ahmadinejad attempted to sack the intelligence minister, Heydar Moslehi, whom he suspected of spying on Mr Mashaie. The supreme leader promptly issued Mr Ahmadinejad with an ultimatum: reinstate the spy chief or resign.
The president resisted that command for 11 days before grudgingly relenting. Effectively, Mr Khamenei successfully called Mr Ahmadinejad's bluff.
The supreme leader then signalled that he wanted his unpredictable president to serve out the remainder of his term in office - but not at any price.
"Khamenei's ideal scenario is to have a weakened president who can absorb responsibility for Iran's economic and political malaise," said Karim Sadjadpour, an associate at the Carnegie Endowment in Washington.
Helping to keep the president in check is a threat by some parliamentarians to impeach him. Among other issues, they accuse him of buying votes in the 2009 election - echoing allegations by reformists two years ago that Mr Ahmadinejad's purported victory was fraudulent.
Rival hardliners are also strenuously resisting Mr Ahmadinejad's attempts to take control of the vital oil ministry, which they suspect he hopes to milk to buy support for his political cronies in forthcoming elections.
Some analysts believe Mr Ahmadinejad will harden his stance on Iran's foreign and nuclear policies to curry favour with hardline clerics during the remainder of his presidency.
Earlier this week he shrugged off the threat of further international sanctions by announcing plans to shift sensitive uranium enrichment to a mountain bunker and triple the output capacity of Iran's nuclear fuel.
"He will probably be able to survive as a lame duck president," said Farideh Farhi, an Iran expert at the University of Hawaii. "But being a lame duck is not what he has shown to be in his character."
If Mr Ahmadinejad is removed, Iranian experts believe he will not go quietly. A Tehran-based analyst, who declined to be named, said: "He's a Kamikaze-type. If he goes down, he will try to drag as many people with him as he can."