Iran's Guardian Council, an unelected body made up of six clerics and six lawyers operating under the oversight of the supreme leader, drew up the restricted list of candidates from the 680 who initially registered.
Eight candidates were approved, two of whom subsequently dropped out.
The final six contenders didn't include any women. Nor did they include Ahmadinejad's aide and protege Esfandiar Rahim Mashaei, who was among those excluded by the Guardian Council.
The only cleric among the candidates, he has close ties to Khamenei and served in Iran's parliament for two decades. He was also Iran's lead nuclear negotiator from 2003 to 2005 and holds seats on several powerful decision-making bodies.
Remembering the 2009 chaos
Four years ago, when allegations of election fraud sparked widespread protests, Iran's police and the Basij, a feared paramilitary group, cracked down on the opposition Green Movement.
Protesters were jailed, and human rights groups alleged many were tortured and killed behind bars while the government quashed the uprising.
Reform politicians representing the movement, including Ahmadinejad's election rival, former Prime Minister Mir Hossein Moussavi, have been under house arrest since 2011.
Despite the unrest, Ahmadinejad's re-election was formally certified by the clerical establishment.