President-elect Hassan Rohani will be confirmed as president on August 3 and publicly inaugurated on August 4.
For many Iranians, the moment has been a long time coming.
"Ahmadi, bye-bye!" protesters chanted before the 2009 presidential vote.
Those chants, and the optimism that the end of Ahmadinejad's era had come, turned out to be premature. Officials announced his victory soon after voting ended and his reelection was endorsed by Supreme Leader Ayatollah Ali Khamenei, sparking mass street protests and allegations of fraud.
Ahmadinejad dismissed the millions of citizens who protested his reelection as "dust and dirt."
But four years later, the farewell chants were heard again and, this time, the term-limited Ahmadinejad really was out.
Relatively moderate cleric Hassan Rohani’s first-round victory in the June election has given many Iranians hope.
A student in Tehran who took part in the 2009 protests told RFE/RL that he was planning to celebrate the end of Ahmadinejad's presidency with friends.
"Finally, those dark days are over. I'm glad I won't have to see [Ahmadinejad] and hear him all the time and he won't be representing me on the international scene," the student said. "He brought us only shame and problems. Tonight and tomorrow, I will sing, 'Ahmadi, bye-bye.'" He declined to give his name out of fear of persecution.
Ahmadinejad's presidency was marked by increasing repression and censorship, intensified pressure on civil society and universities, tensions with the international community, economic mismanagement, and soaring consumer prices.
He steadfastly defended his policies and denied that human-rights violations increased under his rule.
For some Iranians, life became so bad over the past eight years that they’re unable to feel joy at Ahmadinejad’s departure.
One supporter of the opposition Green Movement, who also requested anonymity, said he feels empty.
"I should naturally feel happy, but I don't and it bothers me,” he said. "His presidency destroyed many things in my life. The tragedy is so deep that I don't even know whether I'm happy that he's gone."
Ahmadinejad's second four-year term began with a brutal crackdown against anyone who challenged his victory. An estimated 70 protesters were killed, hundreds were detained, put on trial, forced into false televised confessions, and many were jailed and tortured.
The increased repression forced dozens of activists and journalists to flee the country.
Among them was journalist Mohammad Hossein Ziya, who had campaigned for opposition leader Mehdi Karrubi.
Ziya told RFE/RL he is neither happy nor sad now that Ahmadinejad's presidency is coming to an end.
"I don't blame Ahmadinejad directly for all the problems and suffering. I'm not trying to acquit him or say that he's guiltless, but the problem is that the end of Ahmadinejad's [presidency] is not the end of the thinking that brought him to power and allowed him to remain in power for eight years," Ziya said. "I'm still concerned, but at least there is some hope because, for now, [Ahmadinejad and his allies] won't have access to officials' domestic and international tribunes to speak on behalf of the Iranian people."
Despite such worries, many were celebrating on social media, including on Twitter, where Iranians have been expressing their feelings about the end of Ahmadinejad's rule under the hashtag #AhmadiByebye.
"Eight very difficult and bad years ended," wrote one person.
"He wasn't a [cleric], but he was much worse than them," another wrote.
"In these eight years, he never gave a straight answer to any question,” read another tweet.
Many comments were critical of Ahmadinejad's often crude language and undiplomatic style. There were also comments blaming him for soaring prices and unemployment and other social ills.
Among the tweets and comments on social media, words of praise were almost nonexistent.
However, Iranian news agencies reported that in the streets of Tehran and other cities, some of Ahmadinejad's fans participated in rallies marking Quds Day while holding posters and banners of support.
"We still support Ahmadinejad," read one banner at Tehran's Friday Prayers, according to a report by the Mehr news agency.
The Iranian president said his goodbye to the Iranian people in an August 2 televised interview in which he provided a long list of what he described as his achievements.
He called himself a humble servant of the Iranian nation and claimed that his government had come to power with the prayers of Iranians.
Commenting on his life after the presidency, Ahmadinejad said that he is not planning to create a political party but he suggested that he will keep making political comments.
"I'm not into [creating] political parties, I haven't experienced it before. But it doesn't mean that I won't make political comments because it is part of my life," he said.
In this, his third "farewell" interview, Ahmadinejad added that he will thank Iranians in yet another interview, and ask for their blessings.
-- Golnaz Esfandiari