Ahmadinejad's disqualification by the conservative-run Guardian Council was no surprise - he had been advised not to run by supreme leader Ayatollah Ali Khamenei who said it would "polarise" the nation.
His populist economics and defiant attitude to the establishment had alienated even Ahmadinejad's hardline backers during his 2005-2013 tenure.
"Once the supreme leader had told him not to stand, it became impossible for him to be cleared by the Guardian Council," said Clement Therme, research fellow for Iran at the International Institute for Strategic Studies.
The mood in Tehran has been subdued - many are disillusioned with Rouhani's failure to kick-start the economy despite broad support for his efforts to rebuild ties with the West, notably through a nuclear deal with world powers that eased sanctions.
Also Read
There has been uproar over a decision by the election commission to ban live TV debates, seen by some as an attempt to prevent embarrassment to some of the candidates or the regime as a whole.
Campaigning, which the Guardian Council announced could begin immediately, had not been supposed to start for another week, so there was little activity today.
"They need that for legitimacy - the turnout is even more important than the result," said Therme.
Iran's elections are tightly controlled, with the Guardian Council allowing just six people - and no women - to stand for the May 19 vote out of 1,636 hopefuls that registered last week.
If no candidate wins more than 50 percent, a run-off between the top two is held a week later.
Rouhani, a politically moderate cleric, squeaked to victory last time with 51 percent in the first round, helped by a divided conservative camp.
The constitution adopted after the 1979 revolution offers only vague guidelines that candidates should possess "administrative capacity and resourcefulness... trustworthiness and piety".
The build-up to the vote has injected more interest than many predicted just a couple of months ago, when Rouhani was seen as a shoo-in for a second term if only because the conservative opposition seemed unable to offer a strong candidate.
Since then, the 56-year-old former judge and cleric Ebrahim Raisi has emerged as a front-runner for the conservatives.
But despite emphasising his care for the poor, many say Raisi's hardline judicial background and entourage will turn off voters.
"He seems like a good and calm person himself, but the people around him are scary," said a tour operator in Yazd, echoing a widely heard sentiment.
Some think he may drop out at the last minute in favour of Tehran mayor Mohammad Bagher Ghalibaf, who came second to Rouhani in 2013.
"Economic problems cannot be solved from behind a desk," he said today.
The other three candidates are seen as support for the main players in the upcoming debates.
Moderate reformists Mostafa Hashemitaba and vice- president Eshaq Jahangiri are expected to defend Rouhani's achievements, while veteran hardliner Mostafa Mirsalim will back up Raisi and Ghalibaf.
There were mixed reactions to Ahmadinejad's disqualification.
Despite controversial rhetoric against Israel that worsened ties with the West, and somewhat reckless financial management, he retained considerable popularity, particularly among the poor.
"He was the kind of president that took risks, like distributing money among people and giving houses to the poor, and he had big ambitions for Iran's nuclear programme. Rouhani doesn't take any risks."
But many were glad to see the back of him.
"It was right for Ahmadinejad to be disqualified but it happened 12 years too late," said one Twitter user.
Disclaimer: No Business Standard Journalist was involved in creation of this content