Iran's supreme leader ordered the president, a close ally, to dismiss his controversial choice of a top deputy, the semi-official media reported Wednesday, in a rare split among the country's top conservatives.

The order is a humiliating setback for Mahmoud Ahmadinejad who has strongly defended his decision to appoint Esfandiar Rahim Mashai, his son's father-in-law, as his first vice president.

Mashai angered hard-liners in 2008 when he said Iranians were "friends of all people in the world — even Israelis." Mashai 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 leads Cabinet meetings in the absence of the president.

Click for photos from Iran.

Ahmadinejad is already in a crisis over opposition claims he stole last month's presidential election from the pro-reform candidate Mir Hossein Mousavi. Supreme leader Ayatollah Ali Khamenei strongly backed Ahmadinejad, who is seen as his protege, in the June 12 election.

"The view of the exalted leader on removed Mashai from the post of vice president has been notified to Ahmadinejad in writing," the semi-official Fars news agency reported Wednesday.

It was not immediately clear if Ahmadinejad would cave in to Khamenei's order, who has the final say on all state matters in Iran.

Another semi-official news agency, ISNA, quoted vice speaker of the parliament Mohammad Hasan Aboutorabi-Fard as saying that Mashai's dismissal was a decision by the ruling system itself.

"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.

Pressure has been mounting on Ahmadinejad to remove Mashai from the top post immediately after he appointed the controversial figure to the post Friday.

But nearly the same time as Khamenei was issuing his order late Tuesday, Ahmadinejad vowed to keep Mashai as his first vice president.

"Mr. Mashai is a pious, caring, supporter of the position of the supreme leader, clean and creative managers of Iran. Why should he resign? ... Mashai has been appointed as first vice president and continues his activities in the government," the official IRNA news agency quoted Ahmadinejad 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.

Ahmadinejad's top adviser, Mojtaba Hashemi Samareh, insisted Tuesday that Mashai won't be removed.

"Mr. Mashai's appointment as fist vice president won't be reconsidered at all," ISNA quoted Samareh as saying Tuesday.

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.

The criticism is a change of focus for hard-liners, who have spent the last few weeks lambasting Mousavi and his supporters for challenging the presidential election. On Saturday, hard-liners accused Rafsanjani of defying Khamenei by using his sermon to encourage opposition supporters to continue their protests.