The move by Supreme Leader Ayatollah Ali Khamenei appeared to show his need to keep hard-liners' support even at the cost of angering the president, a close ally - at a time when Khamenei is facing unprecedented opposition after the disputed June 12 election.
President Mahmoud Ahmadinejad's appointment for his top vice president sparked a deep split within the hard-line camp to which he belongs. A chorus of ultra-conservative clerics and politicians denounced his choice, Esfandiar Rahim Mashai, while Ahmadinejad had strongly defended the appointment.
Mashai is a relative by marriage to Ahmadinejad - his daughter is married to the president's son. Mashai angered hard-liners in 2008 when he said Iranians were "friends of all people in the world - even Israelis." He was serving as vice president in charge of tourism and cultural heritage at the time.
Iran has 12 vice presidents, but the first vice president is the most important because he succeeds the president if he dies, is incapacitated, steps down or is removed. The first vice president also leads Cabinet meetings in the absence of the president.
After days of controversy, Khamenei ruled. "The view of the exalted leader on the removal of Mashai from the post of vice president has been given to Ahmadinejad in writing," the semiofficial Fars news agency reported Wednesday.
It was an expansion of the already broad powers of Khamenei, who has the ultimate say in state affairs in Iran. The supreme leader is believed to informally weigh in on senior government appointments behind the scenes. But he does not have a formal role in approving appointments and it is extremely rare for him to order an official's removal.
In the election dispute, Khamenei strongly supported the president, who is seen as his protege, declaring valid the results that showed Ahmadinejad's re-election. Opposition leader Mir Hossein Mousavi claims he won the election and Ahmadinejad's victory is fraudulent, and hundreds of thousands of supporters marched in the street in the weeks after the election.
A fierce crackdown suppressed the massive street protests. But the opposition continues to press its claims that Ahmadinejad's government is illegitimate. More importantly, the clerical leadership that Khamenei in theory leads has been split, with many moderate clerics angered by the handling of the election crisis or outright supportive of Mousavi.
That has made Khamenei more reliant on hard-line clerics for support.
It was not immediately clear if Ahmadinejad would cave in to Khamenei's order.
Ali Akbar Javanfekr, top media adviser to Ahmadinejad, said on Tuesday that the president won't change his mind over the controversy. But it was unclear if his comments came before or after the supreme leader's order.
"The president makes his decisions ... within the framework of his legal powers and on the basis of investigations carried out. Experience has proved that creating baseless controversies won't influence the president's decision," Javanfekr said in his blog.
Nearly the same time as Khamenei was issuing his order late Tuesday, Ahmadinejad vowed to keep Mashai.
"Mr. Mashai is a supporter of the position of the supreme leader and a pious, caring, honest and creative caretaker for Iran ... Why should he resign?" the official IRNA news agency quoted Ahmadinejad as saying. "Mashai has been appointed as first vice president and continues his activities in the government."
The deputy speaker of the parliament, Mohammad Hasan Aboutorabi-Fard, meanwhile, said that Mashai's dismissal was a decision by the ruling system itself, according to the semiofficial ISNA news.
"Removing Mashai from key posts and the position of vice president is a strategic decision of the system ... Dismissal or resignation of Mashai needs to be announced by the president without any delay," ISNA quoted him as saying late Tuesday.
Iran's state television didn't report Ahmadinejad's comments supporting his deputy. A conservative Web site said TV officials had orders from higher officials not to do so.
In his first term, Ahmadinejad had several tussles with his own hard-line camp over appointments, some of whom were seen as not qualified for their posts. In most cases, Khamenei stayed on the sidelines of those disputes.
Last year, the supreme leader rebuked Mashai, calling his Israel comments "illogical," but he also demanded that the flap over the comments be put the rest and expressed support for Ahmadinejad. Mashai remained in his position.
Mashai also angered many of Iran's top clerics in 2007 when he attended a ceremony in Turkey where women performed a traditional dance. Conservative interpretations of Islam prohibit women from dancing.
He ran into trouble again in 2008 when he hosted a ceremony in Tehran in which several women played tambourines and another one carried the Quran to a podium to recite verses from the Muslim holy book.