For conservatives, the election represents a chance to restore the values of the 1979 revolution, which requires elected officials to be subordinate to the Shi'ite Muslim clergy and supreme leader. Photograph:( Reuters )
Vote counting began in Iran on Saturday after a high turnout in an unexpectedly tight presidential election pitting President Hassan Rouhani, who wants to normalise ties with the West, against a hardline judge who says he has already gone too far.
More than 40 million votes were cast, the interior ministry said, indicating a turnout of about 70 per cent in Friday's vote, roughly similar to the showing in 2013 elections when Rouhani swept into office in a landslide victory.
Voting was extended by six hours because many people were still waiting in line. Iranian newspapers praised the turnout, carrying headlines like "a historical victory for Iranians".
Pro-reform news websites said Rouhani was the victor. They offered no evidence, but the big turnout could favour Rouhani, whose backers' main worry has been apathy among reformist-leaning voters disappointed with the slow pace of change.
Rouhani, 68, who took office promising to open Iran to the world and give its citizens more freedom at home, faced an unexpectedly strong challenge from hardliner Ebrahim Raisi, a protege of supreme leader Ali Khamenei.
The election is important "for Iran's future role in the region and the world", Rouhani, who struck a deal with world powers two years ago to curb Iran's nuclear programme in return for the lifting of most economic sanctions, said after voting.
Raisi, 56, has accused Rouhani of mismanaging the economy and has travelled to poor areas, speaking at rallies pledging more welfare benefits and jobs.
He is believed to have the backing of the powerful Revolutionary Guards security force, as well as the tacit support of Khamenei, whose powers outrank those of the elected president but who normally steers clear of day-to-day politics.
"I respect the outcome of the vote of the people and the result will be respected by me and all the people," Raisi said after voting, according to the semi-official Fars news agency.
However, Raisi later appeared at the Ministry of Interior in Tehran on Friday and complained of a shortage of ballot sheets at many polling stations, according to Fars. More ballot sheets were subsequently sent out, the agency reported.
In the last election, Rouhani won more than three times as many votes as his closest challenger. But this time the outcome might be much closer, as other conservative rivals have backed out and thrown their support behind Raisi.
The Guards and other hardliners hope that a win for Raisi will give them an opportunity to safeguard economic and political power they see as jeopardised by the lifting of sanctions and opening of the country to foreign investment.
During weeks of campaigning, the two main candidates exchanged accusations of corruption and brutality in unprecedentedly hostile television debates. Both deny the other's accusations.
Rouhani has urged the Guards not to meddle in the vote, a warning that reflects the political tension. Suspicions that the Guards and the Basij militia under their control falsified voting results in favour of hardliner Mahmoud Ahmadinejad led to eight months of nationwide protests in 2009, which were violently suppressed.
For ordinary Iranians, the election presents a stark choice between competing visions of the country.
Rouhani, known for decades as a mild-mannered establishment insider rather than a gung-ho reformer, has taken on the mantle of the reform camp in recent weeks, with fiery campaign speeches that attacked the human rights records of his opponents.
"I voted for Rouhani to prevent Raisi's victory. I don't want a hardliner to be my president," said Ziba Ghomeyshi in Tehran. "I waited in the line for five hours to cast my vote."
Many pro-reform voters are still lukewarm Rouhani supporters, disappointed with his failure to make broader changes during his first term. But they are anxious to keep out Raisi, who they see as representing the security state at its most fearsome: in the 1980s he was one of four judges who sentenced thousands of political prisoners to death.
"I am on my way to vote for Rouhani. I like his detente policy with the world. I know he is not a reformist, but who cares? What matters is that he is not Raisi," government employee Yousef Ghaemi, 43, said by phone in the western city of Kermanshah.
For conservatives, the election represents a chance to restore the values of the 1979 revolution, which requires elected officials to be subordinate to the Shi'ite Muslim clergy and supreme leader.
"I cast my vote already - I voted for Raisi because he is a follower of Imam Khamenei. He will not confront the leader if elected. He will protect our Islamic identity," said Mehran Fardoust, 36, a shopkeeper near the Imam Reza Shrine in the holy city of Mashhad, Raisi's home town.
Despite the removal of nuclear-related sanctions in 2016, lingering unilateral US sanctions that target Iran's record on human rights and terrorism have kept foreign companies wary of investing, limiting the economic benefits so far.
Raisi has focused his campaign on the economy, visiting rural areas and villages and promising housing, jobs and more welfare benefits, a message which could have resonated with millions of poor voters angry at the Tehran elite.
If no candidate wins more than 50 per cent of the vote, the top two, presumably Rouhani and Raisi, will face each other a second time in a run-off in a week.