Former Iranian President Mahmoud Ahmadinejad flashes the victory sign as he arrives at the Interior Ministry to register his candidacy for the upcoming presidential elections, in Tehran. Picture: Ebrahim Noroozi/AP

Tehran - Iran's former president Mahmoud Ahmadinejad has registered as a candidate for the May 19 presidential elections, despite being told not to by the country's supreme leader.

Ahmadinejad registered together with his long-time deputy Hamid Baghaei at the Interior Ministry on Wednesday.

Last year, Iran's Supreme Leader Ayatollah Ali Khamenei told Ahmadinejad not to run for another term.

Ahmadinejad, 60, appeared to consent at first, but last week announced that he would support the relatively inexperienced Baghaei in the election against incumbent Hassan Rowhani.

Khamenei had only advised him not to run and not forbidden it, Ahmadinejad said after registering.

When asked why he had consistently denied intending to run in recent months, the former president reacted with a smile.

Ahmadinejad is a controversial figure, both in Iran and abroad.

Former Iranian President Mahmoud Ahmadinejad, seated center, flashes the victory sign as he registers his candidacy for the upcoming presidential elections at the Interior Ministry in Tehran. Picture: Ebrahim Noroozi/AP

President Hassan Rowhani accused Ahmadinejad of causing serious damage to the country during his eight-year tenure from 2005 to 2013.

Ahmadinejad's uncompromising nuclear policy led to sanctions, which plunged the oil-rich country into an economic crisis.

His anti-Semitic remarks, verbal attacks on Israel and denial of the Holocaust also left Iran isolated internationally.

Ahmadinejad's divisiveness explains Khamenei's attempt to prevent him from running again.

Iran's clergy and ultra conservatives are also hoping for a strong candidate to rival Rowhani, in the form of 57-year-old conservative cleric Ebrahim Raisi.

Ahmadinejad's candidacy would mean that votes from Rowhani's opponents would be split between two camps.