Ahmadinejad was in office from 2005-2013, but his 2009 win came under a cloud of vote-rigging accusations.
Iran's former hardline President Mahmoud Ahmadinejad took the shock move on Wednesday of registering for next month's presidential election, going against the advice of the supreme leader. Persian social media erupted on 6 April when Raisi - the favourite candidate to replace the Supreme Leader, Ayatollah Khamenei - announced his intention to run for president.
Ahmadinejad previously said he wasn't going to run after Supreme Leader Ayatollah Ali Khamenei advised him not to.
In 2009, Ahmadinejad's re-election was followed by one the largest protests to hit the country since the Islamic Revolution three decades before.
The Supreme Leader said previous year, without naming him, that Ahmadinejad's candidacy is not in the interest of the Iranian people, therefore calling on him not to run.
He vowed to serve the Iranians, and try hard for the establishment of "justice and freedom" if he was re-elected as President.
"Someone came to see me and considering his own interests and the interests of the country, I told him he should not participate in that matter [elections]", Khamenei was quoted by his official website a year ago, referring to Ahmadinejad. There was no immediate reaction from the supreme leader's office.
Ahmadinejad is a controversial figure, both in Iran and overseas.
During the registration in Iran's Interior Ministry, Ahmadinejad, expressed hope for victory.
"Khamenei will not forget this move, which was aimed to harm his image", said political analyst Hamid Farahvashian.
Ahmadinejad presided over two of the most turbulent terms in the Iranian Republic.
Ayatollah Khamenei ultimately calls the shots in Iran, where the president can only influence policy, not decide it.
But Mr Ahmadinejad told reporters on Tuesday that had been "just advice".
"Ahmadinejad's faction is still alive". "I'll be serving Mr Baghaei with all my power". Even many hard-liners believe the council will disqualify Ahmadinejad and Baghaei, who was briefly jailed on corruption charges.
Iran under Ahmadinejad had its nuclear and defense program accelerated.
Like all those bidding to run - including incumbent moderate President Hassan Rouhani who secured the lifting of numerous worldwide sanctions by signing the nuclear deal in 2015 - Ahmadinejad will have to get past the Guardian Council to make it on to the ballot paper. "The recovery, however, has yet to reach most ordinary Iranians". Ahmadinejad said his only intention was to support Baghaie, without offering further explanation.
Ebrahim Raisi, a judge who now heads the powerful Imam Reza charitable foundation in the Shiite Muslim holy city of Mashhad, topped the shortlist.style="text-align: center;"