When he was swept to office four years ago with three times as many votes as his nearest challenger, Iranians held high hopes that he could fulfil his promises to reduce the country's isolation overseas and bring more freedoms at home.
Interior Minister Abdolreza Rahmani Fazli announced the vote tallies in a televised news conference, based on a count of more than 99 percent of the ballots.
The Interior Ministry reported that 40 million ballots were cast out of 56 million registered voters, representing a 70 percent turnout, similar to the 2013 elections which brought Rouhani to power.
Four eligible candidates ran in Friday's elections: two conservatives, Raisi and Mostafa Mirsalim, in addition to two moderates, Rouhani and Mostafa Hashemitaba.
Iranian voters wait for a polling station to open during the presidential election in Tehran, Iran, May 19, 2017. Election officials extended voting hours at least three times at the more than 63,000 polling places to accommodate the crowds.
Iran since has resumed crucial oil exports to Europe and concluded billion-dollar deals to purchase passenger planes, but the effects have yet to trickle down to most Iranians, creating an opening for hardliners who feel Rouhani gave too much away.
"Instead of using the capable hands of our youths to resolve problems, they are putting our economy in the hands of foreigners", Raisi said at a final rally in the holy city of Mashhad on Wednesday.
Trump hit by twin Russian Federation bombshells as he departs for foreign trip
That flies in the face of the White House's public insistence that Comey's dismissal was not linked to his ongoing investigation. He says his memo is not a finding of official misconduct and is not a statement of reasons to justify Comey's firing.
He pushed boundaries during the campaign, criticising the continued arrest of reformist leaders and activists, and calling on security agencies to not interfere in the vote. Before the victory of the Islamic Revolution in 1979, President Rouhani used to preach against the Shah (the toppled king of Iran), and had to change his name to avoid detection by the secret services.
Iran's 12th presidential election was held on Friday.
Mr Rouhani is promising "progress and hope" and his supporters have come out in droves, at one point even filling a stadium with a huge crowd doing the Mexican wave. Rouhani advocates the foreign investment promised by the nuclear deal but which has been held up by concerns over remaining punitive sanctions.
For ordinary Iranians, the election presented a stark choice between competing visions of the country. The Saudis are a strong US ally and arch-enemy of Iran; the largely Sunni Saudis strongly opposed President Obama's outreach and nuclear deal with the Persian Shia power. That includes Rouhani openly criticizing hard-liners and Iran's powerful Revolutionary Guard, a paramilitary force now involved in the war in Syria and the fight against Islamic State militants in neighboring Iraq.
Of a total of 25,966,799 ballots that have been count, more than 784,000 (3.02 percent) have been declared spoilt votes.
"Rouhani also has a great team of technocrats, like Foreign Minister Mohammad Javad Zarif, and Vice President Eshaq Jahangiri", said one voter who identified himself as "Sam". "Both might be reformist candidates for the next presidency", Sam added.