Flanked by reporters after filling out registration forms and making a victory sign, Ahmadinejad said: "The Leader advised me not to participate in the elections, and I accepted". "There is extensive pressure on me from dear people of different walks of life as their small servant to come to the election".
Ahmadinejad's firebrand style could prove appealing for hard-liners seeking a tough-talking candidate who can stand up to U.S. President Donald Trump.
In 2011, Ayatollah Khamenei was so annoyed by Mr 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 Mr Ahmadinejad briskly dismissed as "academic".
Ahmadinejad's decision to contest re-election is believed to be a mighty development in the purview of Syria war for which Saudi Arabia supports US. The final election ballot will be announced on April 26-27, and campaigning will officially begin on April 28.
Ahmadinejad's former vice president, Hamid Baghaei, also registered his candidacy, and some theorize that the two are running in an effort to increase their election odds, as there's speculation that Ahmadinejad won't make it past the Guardian Council's vetting.
Mr Ahmadinejad's eight years in office saw a tightening of global sanctions on the Islamic Republic to curb its nuclear program.
More than 120 prospective candidates submitted their names as candidates on the first day of registration on Tuesday, including six women and seven clerics.
Ahmadinejad left office in August 2013 after two troublesome four-year terms, which left Iran divided, isolated and struggling to find its footing economically. According to Iran's Fars news agency, Khamenei warned Ahmadinejad, "It's not in your own or the country's best interests to run". It is here where the Supreme Leader could use his influence to disapprove of Ahmadinejad's candidacy. He left behind a broken, destroyed country that suffered from problematic foreign relations and a deep economic crisis as the result of global sanctions resulting from the nuclear program.
He added: "Some people say that the [supreme leader's] advice was meant to completely forbid [me from running], but what the leader said was just advice".
His disputed re-election in 2009 sparked massive protests and a sweeping crackdown in which thousands of people were detained, dozens killed and others tortured.
Registrations are open until Saturday and will be vetted by a clerical body by the end of the month.
Mr Rouhani and his allies have criticisedMr Ahmadinejad's free-spending policies for fuelling inflation and accuse him of wasting Iran's oil revenues.
The registration process is to last for three more days and Iranians will go to the polls on May 19.