Analysts thought Mr Ahmadinejad was down and out - but his fans disagree
By Jon Leyne
BBC News, Tehran
As Iran approaches its presidential election, the country is more divided than at any time since the revolution.
Huge crowds have been taking to the streets to support rival candidates. Many people believe that President Mahmoud Ahmadinejad is in real danger of losing the election.
But on the campaign trial with Mr Ahmadinejad, you can see he still has a large, hard core, of devoted supporters.
In the small town of Robat Karim the crowds flocked around his motorcade, delaying progress to a crawl.
Mr Ahmadinejad was in no hurry.
As he left the rally, a woman approached him asking help to cure her child. Amid the crush, there was no attempt to turn her away. Instead the president of the Islamic Republic discussed her problems for minutes on end.
It is a scene I have witnessed time and again. Mr Ahmadinejad, man of the people, with time for everyone.
For the outside world, it is the fiery rhetoric that everyone hears.
The president is still revered by many
Mr Ahmadinejad's condemnation of the United States and Israel, his questioning of the Holocaust, and his championing of Iran's nuclear programme.
Time and again those issues come up as Mr Ahmadinejad works the crowd - a true populist in action.
But it is the moment when he promises help for local problems that the crowd really loves.
In Robat Karim, he promised help to this neglected town to be recognised as a city.
Across the country, he has pledged Iran's oil wealth for new schools, mosques and leisure facilities - sometimes leaving the government's financial advisers holding their heads in their hands.
At every rally, the women, clad in the long black religious cloak - the chador - press forward with scrawled notes for the president.
Mir Hossein Mousavi has emerged as a surprise challenger
They believe that one word from the president can help solve their housing problems, or their healthcare.
Sometimes the fervour seems almost religious, as they reach forward to the president. I saw several women at his rallies in hysterical floods of tears.
It is not hard to find Ahmadinejad supporters in villages, or small towns like Robat Karim.
They believe he has helped the poor and stood up for the interests of Iran.
But when you speak to the middle classes in Tehran, they simply cannot believe that anyone of an independent mind can vote for him.
Rallying the opposition
In the last week of the election campaign they have been pouring on to the streets of Tehran chanting "Mahmoud bye bye".
In this country where the personal is political, you can guess whom they support by the dress code. For Ahmadinejad opponents, the women often have their headscarves teetering on the very back of their well-coiffed hair. No black chadors here.
The sight of so many supporters on the streets, so vociferous, is unprecedented
The opposition crowds are made up mostly of young people - often university students, often women - frustrated that they cannot meet their aspirations in President Ahmadinejad's Iran.
They are fascinated by US President Barack Obama and despise Mr Ahmadinejad's "death to America" rhetoric.
Former Prime Minister Mir-Hossein Mousavi has become their unlikely champion.
Aged 67 with grey hair and a dull speaking manner, he can hardly be described as inspirational.
Both candidates have drawn huge crowds
But he has taken on board their aspirations. And for the first time in the history of the Islamic Republic, he has been joined on the campaign trail by his wife, Zahra Rahnavard.
All this is about more than just two candidates.
It is about two visions of Iran. It is a division that has been deep in Iran since the Islamic revolution, and before - a divide between traditionalists and modernists.
But in this election it has become more stark than ever before.
As Mr Ahmadinejad has continued to make controversial allegations against his opponents, the split has been further polarised.
The sight of so many supporters on the streets, so vociferous, is unprecedented.
Under President Ahmadinejad, anti-government demonstrations have been almost unheard of.
Suddenly the pressure valve has been released.
With no reliable opinion polls and huge crowds attending the rallies of both main candidates, it is hard to make predictions.
It seems likely the election will go to a second round on 19 June.
Whoever wins, already Iran has surely been changed for ever.