Millions of Iranians voted late into the night Friday to decide whether incumbent President Hassan Rouhani deserves another four years in office after securing a landmark nuclear deal, or if the sluggish economy demands a new hard-line leader who could return the country to a more confrontational path with the West.
Preliminary vote tallies have Rouhani ahead with 22.8 million votes, out of 38.9 million counted so far.
Mostafa Aqa-Mirsalim and Mostafa Hashemi-Taba, the other two candidates, so far received 455,211 and 210,597 votes respectively.
The interior ministry said more than 40 million votes had been cast.
The election was important "for Iran's future role in the region and the world", Rouhani said on Friday after voting.
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. Yet the extent of his success would depend on the cooperation of the Iran's conservative establishment, led by Supreme Leader Ayatollah Ali Khamenei, who implicitly supported Raisi during the campaign.
Rouhani, 68, secured an impressive lead of 57 percent in a presidential race which drew out at least seven of every 10 voters in the country.
"I respect the outcome of the vote of the people and the result will be respected by me and all the people", Raisi said, according to the semi-official Fars news agency.
Rouhani has urged the Guards not to meddle in the vote, a warning that reflects the political tension.
Iranian President Hassan Rouhani has won re-election by a large margin.
Ali Vaez, Iran analyst for the International Crisis Group, a think tank said: "Rouhani's vote, particularly in rural areas, shows that Iranian people no longer believe in economic populism and radical change". Polling stations had been due to close at 8pm local time but due to the turnout, voting hours were extended until midnight.
Rohani, who oversaw the breakthrough nuclear deal with world powers to ease worldwide sanctions, has promised engagement with the West and more freedom for Iranians.
Friday's election was largely seen to be between Rouhani and conservative challenger Raisi.
Six candidates had been approved after vetting by the Guardian Council to run in the election.
In a series of stump speeches, Rouhani attacked hardliners over their opposition to greater personal freedoms, corruption and conservative-controlled institutions that don't pay tax. Opposition websites have said Green Movement leaders Mir Hossein Mousavi and Mahdi Karroubi both have endorsed Rouhani against Raisi.
Rouhani has had a tough time defending the agreement and his opponents have accused him of not making good on his promises.