Rouhani, who championed the deal to lift most sanctions on Iran in return for curbs on its disputed nuclear program, is a staunch supporter of engagement with the West and liberal reforms to the economy, now dominated by state institutions. Around 1,350,294 million youths were eligible to voter for the first time in their lives as the voting age in Iran is above 18 according to the law.
But Mr Rouhani is widely seen as having overpromised when he sold the nuclear deal, and many have been disappointed with the economic benefits that flowed from lifting anti-nuclear sanctions.
In the last election, Rouhani won more than three times as many votes as his closest challenger.
Ayatollah Khamenei described the 2017 elections as very important, saying the destiny of the country is in the hand of the masses.
Results from urban areas - much more likely to support Mr Rouhani - have not yet come in.
Rouhani's main rival in the election was Ebrahim Raisi, a principlist figure. "He kept the shadow of war far from our country".
For voter Hassan Rahmani, 34, in northern Tehran, maintaining good relations is key to Iran's future. In Tehran, even political prisoners such as prominent human rights lawyer Narges Mohammadi, cast their votes inside the notorious Evin prison.
Mr Raisi is a protege of Iran's supreme leader Ayatollah Ali Khamenei.
Diritti tv: obiettivo Lega-Infront assegnazione metà giugno
La conseguenza è stata la convocazione dell'assemblea di lega per giovedì prossimo, la prima con Tavecchio commissario. Possibile rivoluzione nei Diritti di trasmissione delle partite di Serie A per il triennio 2018-2021 .
Interior Minister Abdolreza Rahmani Fazli said that voting for presidential and local elections in Iran was extended for the third time stressing that polling will definitely end at 12 pm local time. "Rouhani gave everything to the US outright" in the nuclear deal.
Two other candidates were also on the ballot - conservative Mostafa Mirsalim and reformist Mostafa Hashemitaba.
Ahmadi also noted that around 40 million votes have been tallied so far, whose results will be made public later.
Masoumeh Ebtekar, the spokeswoman for the students who held 52 Americans hostage at the Iranian embassy, is now one of Iran's vice-presidents.
However, the election does not mean that Iran's next president will necessarily be able to carry out his campaign promises.
"The enthusiastic participation of Iranians in the election reinforces our national power and security", said Rouhani as he voted in Tehran.
All candidates for elected office must be vetted, a process that excludes anyone calling for radical change, along with most reformists. The Instagram account of Rouhani ally, former president Mohammad Khatami, showed a picture of Rouhani making a victory sign and ran the slogan "Hope prevailed over isolation". Officials say more than 40 million people voted. But he remains subordinate to the supreme leader, who is chosen by a clerical panel and has the ultimate say over all matters of state.
Rouhani, meanwhile, is essentially running for re-election as an outsider, and is backed by Iran's reformist camp. Allegations of voter fraud marred the country's 2009 election, which saw hard-line President Mahmoud Ahmadinejad secure a second term amid widespread unrest.
At recent rallies, his supporters chanted the names of reformist leaders under house arrest since 2011 for their part in mass protests two years earlier.