Ahmadinejad, a vocal critic of the West, served two terms as president between 2005 and 2013.
President Hassan Rouhani and leading hardliner Ebrahim Raisi have both been approved by the Guardian Council.
A final list of candidates for the 19 May poll will be announced on 27 April.
More than 1,600 candidates sought to stand, but only about six are selected by the Guardian Council, the clerical body which vets candidates.
The nominations of Rouhani and Raisi will lead to a showdown between bitterly divided political camps.
Rouhani was elected by a landslide in 2013, on a platform of ending the country's diplomatic isolation and creating a freer society.
Two years later his government and six other countries reached a landmark deal, in which Iran agreed to curb its sensitive nuclear activities in return for the lifting of economic sanctions.
Raisi is a seyed, meaning he traces his genealogy back to the Prophet Muhammad. He has a reputation for his uncompromising stance on key issues and is rumoured to be supported by Supreme Leader Ayatollah Ali Khamenei.
Ahmadinejad caused widespread shock when he registered as a candidate last week in defiance of Khamenei's advice.
Last year the Supreme Leader warned Ahmadinejad that such a move was "not in his interest and that of the country".
Khamenei appoints about half of the Guardian Council. Ahmadinejad's close ally Hamid Baghaie was also barred from standing in the election.
Rouhani and Raisi are expected to focus their campaigns on the state of the economy as well as the nuclear deal, which has been hailed by the president as his most significant success over the four years he has been in office.
Other candidates given the go-ahead to compete in the vote are conservative Mostafa Mirsalim, Tehran mayor Mohammad Bagher Ghalibaf, reformist Mostafa Hashemitaba and Vice President Eshaq Jahangiri.