The other candidates selected were hardliners Ebrahim Raisi and Mohammad Bagher Ghalibaf, conservative Mostafa Mirsalim, former minister Mostafa Hashemitaba and Rouhani's ally and vice-president Eshaq Jahangiri.
Both Ahmadinejad and his close ally Hamid Baghaie were barred from running by the Guardian Council.
Signup to our newsletter and follow us on Facebook and Twitter!
The former hardline president, who ruled from 2005 to 2013, shocked everyone by registering as a candidate last week against the advice of supreme leader Ayatollah Ali Khamenei.
More than 1,600 candidates registered to run in the May 19 election, but the Guardian Council only ever selects around half a dozen.
More than 130 women registered but none has ever been allowed to stand.