Shortly before polls were due to close, state television reported that voting had been extended by at least two extra hours to 8:00 pm (1530 GMT) to cope with a "rush of voters". Rouhani and Raisi are the main rivals in the race.
For the presidential competition, the candidates are incumbent President Hassan Rouhani, the Custodian of Imam Reza (AS) Holy shrine Ebrahim Raeisi and former minister of Culture and Islamic Guidance Mostafa Aqa Mirsalim and former Minister of Physical Education Mostafa Hashemi Taba.
One of Rouhani's major achievements is considered to be the landmark nuclear deal struck between Iran and five permanent UN Security Council members plus Germany in 2015, which enabled the oil-rich country to escape most of the economic sanctions plaguing its economy and to boost oil production and exports. Around 56 million were eligible to do so.
"Rouhani will apply his ever-increasing efforts for the dignity of Iran" in his next term, the reformist said.
Supreme Leader Ayatollah Ali Khamenei, Iran's most powerful man and decision maker, symbolically cast the importance of the election's first vote and asked Iranians to go out and vote. He called for a large turnout, saying "the country is in the hands of all people".
As his campaign for re-election got under way, many reformist voters said they were disillusioned, an apathy Rouhani's allies saw as the biggest threat to his re-election.
So, Rouhani attracted more votes in the provinces as follows: West Azerbaijan, Alborz, Ilam, Bushehr, Sistan and Baluchestan, Qazvin, Kurdistan, Kerman, Kermanshah and Yazd. "He kept the shadow of war far from our country".
Across the country, over 71,000 election monitors were deployed at almost 130,000 ballot boxes and more than 300,000 police officers were stationed to ensure security of 63,000 polling places.
"He has just looked after the rich and people who are Western".More news: Who Has France's President Emmanuel Macron Picked for his Government?
More news: In New Orleans, Confederate monuments are gone _ Lee last
More news: How to Prevent Ransomware Attacks
"The next president should not be someone who makes the enemies happy when he is elected", said Kermani, who is an adviser to Khamenei.
Rouhani has history on his side in the election.
Raisi has tried to gain support by promising more financial support to the working class and to triple cash handouts to the poor.
Four candidates are vying for the Iranian presidency. Other polls have shown support for both Rouhani and his signature initiative, the nuclear deal, dropping in recent months.
"The wide mobilisation of the hardline groups and the real prospect of Raisi winning scared many people into coming out to vote", said Nasser, a 52-year-old journalist.
Canada and Iran severed diplomatic relations in 2012 under the Harper government, and Iran still has no official diplomatic presence in Canada - such as an embassy - where Iranians can vote. President Donald Trump's tougher stance on Iran has stoked concern as well, though his administration this week took a key step toward preserving the Obama-era nuclear deal.
Global affairs researcher Foad Izadi, of Tehran University, said Rouhani may now have the leverage to push for more freedoms, despite opposition from the conservative-dominated judiciary and security services. No woman has been approved to run for president.
Ultimately, it is the country's Supreme Leader Ayatollah Ali Khamenei who holds sway over Iran's foreign policy.