Iranian leaders
Ayatollah Ali Khamenei, left, greets former judiciary chief Ayatollah Mahmoud Hashemi Shahroudi as President Mahmoud Ahmadinejad sits at center during a religious ceremony in Tehran in a photo released by the office of the Iranian supreme leader. (Associated Press / May 22, 2011)
Supreme leader Ayatollah Ali Khamenei wanted to send his onetime protege Mahmoud Ahmadinejad an unmistakable message: You're replaceable.

The Iranian president had been skipping Cabinet meetings, apparently over Khamenei's decision to overrule his firing of the country's intelligence chief. So Khamenei asked a conservative lawmaker to begin assembling a caretaker Cabinet, just in case the president resigned or had to be removed, said an Iranian official close to the politician.

Ahmadinejad eventually returned to work. But he also had a message for Khamenei: I can still make a big mess.

He recently defied the nation's constitutional watchdog, and Khamenei, by launching a drastic restructuring of the country's government and naming himself caretaker minister of the country's vast oil and gas resources, saying, "The president has the authority to replace ministers and be the caretaker himself." But on Friday he was overruled again, by the country's powerful Guardian Council.

The eyebrow-raising dispute between Ahmadinejad's camp and the conservative clerical and political class is rippling across the world — and igniting concern inside Iran that it weakens the country's ability to project power internationally at a moment of historic instability across the region.

Ahmadinejad and the conservative factions, which have long been suspicious of the president's populist politics and anticlerical religious attitudes, are skirmishing feverishly over the country's future, positioning themselves for survival once the frail, 71-year-old Khamenei dies.

Ahmadinejad has embarked on nothing short of a program to reinvent the Islamic Republic, adding touches of fiery nationalism and a version of evangelical Islam to the country's identity. But his populist giveaways and talk of impending apocalypse threaten not only economic interests and the traditional power of the clergy but Khamenei himself.

The supreme leader, his allies and other factions want to keep Ahmadinejad in check as he seeks to expand his powers and build a political future for himself beyond the constitutionally mandated end of his second term in 2013.

They've tried a number of ways to clip his wings, including charging members of his entourage with sorcery and accusing the president himself of being bewitched by his controversial chief of staff, Esfandiar Rahim Mashaei, whom they describe as leading a "pervert current" within the leadership.

This season of open political warfare within Iran's political establishment isn't likely to destabilize a regime born with deep factional cracks 32 years ago. But even officials inTehran have warned in repeated public statements that the infighting may deepen rifts that could be exploited by rivals abroad.

"It's an indication that the regime is in a lot of trouble," said Alireza Nader, an Iran expert at Rand Corp. "It can't handle the internal and external pressure. There are people in the country who can't agree what to do about the future of the country, so they're at each other's throats."

The crisis highlights the undemocratic warts of Iran's political system just as a pro-democracy wave has swept across the Middle East. It has also embroiled figures within the highest levels of the country's national security establishment, an unwelcome domestic political distraction for Iranians seeking to fend off pressure over the country's nuclear program and extend its influence across the region.

Ahmadinejad falls into the mold of ambitious populist politicians as varied as Andrew Jackson andHugo Chavez, trying to use his presidential pulpit to launch vast social changes and make his mark. But he's stifled by entrenched political, military and economic interests in the clergy, political establishment, business world and armed forces — all rallying around Khamenei — who want to limit his future, which for now looks grim.

Ahmadinejad is not going down quietly. Much to their chagrin, Khamenei and allies who brought Ahmadinejad to power now find themselves the target of the same ruthless and confrontational tactics he has used against the country's reformists and its international enemies.

"This is his character," said professor Mahjoob Zweiri, an Iran expert at Qatar University in Doha. "He was not able to change that attitude when it came to conservatives. This is something in his blood. This is something in his nature."

Iran's powerful conservative establishment hailed Ahmadinejad when he was serving as a distracting lightning rod on the international scene and taking on its reformist enemies. It rallied behind him after his disputed 2009 reelection, when people poured into the streets to protest voting irregularities.

Analysts abroad and officials in Tehran, mostly speaking on condition of anonymity in a series of conversations in recent weeks, say the country's elite may now rue the day Ahmadinejad was elected.

"He's a hooligan and he proceeds in his projects by being extremely rude and ignoring everyone else," said Mehdi Khalaji, an Iran expert at the Washington Institute for Near East Policy.

Analysts say intense mistrust between the factions ahead of 2012 parliamentary elections and the 2013 presidential election led to the alleged electronic surveillance of Mashaei's office that caused Ahmadinejad to fire the intelligence chief and escalate tensions within the political establishment.