May’s election is widely expected to be won by current moderate President Hassan Rouhani, best known outside the country for his negotiation of a nuclear deal with world powers.
Mr Rouhani was endorsed by Supreme Leader Ayatollah Ali Khamenei in September 2016, who also recommended that Mr Ahmadinejad should not run. Without naming the former president, he said one candidate should not seek office as it would bring about a “polarised situation” that would be “harmful for the county”.
Conservative parties in Tehran’s parliament have so far been unable to coalesce around a single candidate.
Election officials appeared stunned, Associated Press journalists said, as they watched the processing of Mr Ahmadinejad’s paperwork. No immediate reaction was forthcoming from the Ayatollah’s representatives.
While the Ayatollah’s September comments were “just advice”, they “do not prevent me from running”, Mr Ahmadinejad told Iranian state media shortly after registering himself as a presidential candidate.
“There is extensive pressure on me from dear people of different walks of life as their small servant to come to the election,” he added.
At least 120 people have submitted their names as candidates for president since registration opened on Tuesday, including several of Mr Ahmadinejad’s allies.
The former president’s firebrand style could prove appealing for hardliners now seeking a tough-talking candidate to stand up to newly elected US President Donald Trump, who made much on the campaign trail of his “tough stance” on Iran.
Analysts observe a Ahmadinejad candidacy could re-ignite the divides in Iranian politics deepened by his turbulent second term in office between 2009-2013.
“[The decision] was an organised mutiny against Iran’s ruling system,” Soroush Farhadian, who backs political reformists, told the AP.
Mr Ahmadinejad remains a controversial figure in Iran. Western belief he was secretly pursuing a nuclear weapons programme led to crippling international sanctions during his time in office, and protests at his 2009 re-election were met with a crackdown which sent hundreds of people to prison and left dozens dead.
Several of his close political allies have since been jailed on corruption charges. Internationally, Mr Ahmadinejad’s frequent comments predicting the demise of Israel and questioning the scale of the Holocaust often raised alarm.
Under Iran’s electoral system all potential presidential candidates must be vetted by a clerical body before they are allowed to run for office. Women and political dissidents are usually vetoed.
Iran goes to the polls on 19 May in an election widely viewed as a referendum on the historic 2015 nuclear agreement. While the deal eased international sanctions in return for curbs on the country’s nuclear programme, the trickle-down effects have yet to be felt by many of Iran’s 80 million-strong population.
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies