Iran's former President Mahmoud Ahmadinejad has been disqualified from running in next month's presidential election, according to state media.

The decision on Thursday was taken by the Guardian Council, a clerical body charged with vetting candidates for the May 19 election.

In a surprise move, Ahmadinejad registered as a candidate last week, despite previously saying he would not stand.

Iran's Supreme Leader Ayatollah Ali Khamenei had previously urged him not to run.

WATCH: Iran's 2017 election

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.

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

The Guardian Council said it had compiled a final list of candidates earlier on Thursday and that the interior ministry would announce their names by Sunday.