ANKARA (Reuters) - Hardline former president Mahmoud Ahmadinejad surprised Iran’s clerical establishment by registering for the May 19 presidential election, defying the Islamic Republic’s Supreme Leader’s warning not to enter the race.

Ex-Iranian President Mahmoud Ahmadinejad reacts as he submits his name for registration as a candidate in Iran's presidential election, in Tehran, Iran April 12, 2017. Tasnim News Agency/Handout via REUTERS

Vilified in the West for his barbs against America and Israel and questioning of the Holocaust, the blacksmith’s son Ahmadinejad has upset predictions before by stealing the show in 2005 when he defeated powerful former president Akbar Hashemi Rafsanjani in a run-off vote.

Supreme Leader Ayatollah Ali Khamenei revealed last year that he had recommended to Ahmadinejad not to enter the contest. But after his registration on Wednesday, Ahmadinejad told journalists that Khamenei’s recommendation was “just advice”, Iranian media reported.

Khamenei praised Ahmadinejad as “courageous, wise and hard-working” after his re-election in 2009, which ignited an eight-month firestorm of street protests. His pro-reform rivals said that vote was rigged.

But throughout Ahmadinejad’s presidency, Khamenei was wary of him, and his insubordination and relentless self-aggrandisement rankled the hardline clergy.

Ahmadjinejad was required to step down because of term limit rules in 2013, when President Hassan Rouhani won in a landslide on a promise to reduce Iran’s international isolation.

After a term out of office, Ahmadinejad is now permitted to stand again under Iran’s constitution, but he still needs the approval of the 12-member Guardian Council which vets candidates, six members of which are appointed by Khamenei.

“His disqualification by the Guardian Council would show that the council is not independent and follows the orders of the supreme leader,” said political analyst Saeed Leylaz.

Khamenei’s backers accuse Ahmadinejad’s camp of pursuing an “Iranian” school of Islam, viewed as an inappropriate mix of religion and nationalism. Ahmadinejad may pay the price for disobeying Khamenei by running for president, analysts said.

“Khamenei will not forget this move, which was aimed to harm his image,” said political analyst Hamid Farahvashian.

In 2011, Khamenei was so annoyed by Ahmadinejad’s hunger for more power that he floated a proposal to change Iran’s constitution to do away with a directly elected presidency altogether, an idea Ahmadinejad briskly dismissed as “academic”.

Slideshow ( 2 images )

“AN AFFRONT TO KHAMENEI”

Khamenei ultimately calls the shots in Iran, where the president can only influence policy, not decide it.

A former officer of Iran’s elite Revolutionary Guards Corps (IRGC), Ahmadinejad relies on Iran’s devout poor, who felt neglected by past governments and helped sweep him to power in 2005. However, his popularity in Iran remains in question.

“Ahmadinejad’s faction is still alive. He enjoys the support of the poor and lower-income in the cities,” said Leylaz.

Rouhani and his allies have criticized Ahmadinejad’s free-spending policies for fueling inflation and accuse him of wasting Iran’s oil revenues.

Ahmadinejad’s critics say his fiery anti-Western talk helped isolate Iran diplomatically. During his term, the U.N. Security Council imposed three sets of sanctions on Iran over its nuclear program.

Rouhani, who engineered Iran’s 2015 nuclear deal with world powers that secured a removal of international financial and trade sanctions against Tehran, is expected to seek re-election.

Although Rouhani won in a single round with more than 50 percent of the vote four years ago when no other candidate won more than 17 percent, he could face a more difficult campaign this time if hardliners unite against him. Many Iranians have grown impatient with the slow rate of improvement in their economic fortunes since the lifting of sanctions last year.

In a move to widen Ahmadinejad’s support, his senior aide Esfandiar Rahim Mashaie in May sent a conciliatory letter to Ahmadinejad’s predecessor as president, Mohammad Khatami, seen as the father of Iran’s reform movement.

Insiders said if disqualified, Ahmadinejad is likely to call on his supporters to back Rouhani, whose main rival is likely to be influential hardline cleric Ebrahim Raisi, who declared his candidacy on Sunday.

“The irony is that by spoiling the conservatives’ game and taking away from Raisi’s voter-base, Ahmadinejad is in fact aiding Rouhani’s re-election,” said senior Iran analyst Ali Vaez of the International Crisis Group.

Raisi, 57, heads Astan Qods Razavi, an organization in charge of a multibillion-dollar religious foundation that manages donations to Iran’s holiest Shi’ite Muslim shrine in the northeastern city of Mashhad.

“Ahmadinejad knows full well that his candidacy is an affront to Khamenei who had publicly barred him from running,” said Vaez. “Disqualifying Ahmadinejad is hard, but not impossible.”