In a surprise move, Mahmoud Ahmadinejad, Iran's former president, has registered as a candidate for next month's presidential election.

Ahmadinejad had previously said he would not stand after being advised not to by supreme leader Ayatollah Ali Khamenei, saying he would instead support his former deputy, Hamid Baghaei, who also registered on Wednesday.

He said he remained committed to his "moral promise" to Khamenei of not running for the May 19 election.

Khamenei's "advice was not a ban", he said at the interior ministry where registration was taking place.

"I repeat that I am committed to my moral promise [of not running] and my presence and registration is only to support Mr Baghaei."

Two turbulent terms

Ahmadinejad left office in August 2013 after two turbulent four-year terms, leaving the country divided domestically, isolated internationally and struggling economically.

In 2009, Ahmadinejad's re-election was followed by one the largest protests to hit the country since the Islamic Revolution three decades before.

Two candidates backed by reformists Mir Hossein Mousavi and Mehdi Karroubi - who have been under house arrest since February 2011 - contested the results.

Both of Ahmadinejad's terms were also marked by anti-Western and anti-Israeli rhetoric, including questioning the Holocaust.

Ahmadinejad's populist approach and humble roots mean that he remains a popular figure among poorer sections of society.