Millions of Iranians joined long queues to vote on Friday, an early sign of strong turnout in an unexpectedly tight presidential election that could determine the future of the country's nascent emergence from international isolation.
The presidential vote pits incumbent Hassan Rouhani, who wants to normalize ties with the West, against a hardline judge who says Rouhani has gone too far and sold out the values of Iran's Islamic revolution to its enemies.
Rouhani, who struck a deal with world powers two years ago to curb Iran's nuclear program in return for the lifting of most economic sanctions, said the election was important "for Iran's future role in the region and the world".
"Whoever wins the election, we should help him to fulfill this important and serious duty," state news agency IRNA quoted him as saying after voting.
Rouhani, 68, who swept into office four years ago promising to open Iran to the world and give its citizens more freedom at home, faces an unexpectedly strong challenge from Ebrahim Raisi, a protege of supreme leader Ali Khamenei.
Raisi has blamed Rouhani for mismanaging the economy and has traveled to poor areas holding 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.
In the last election, Rouhani won more than three times as many votes as his closest challenger. But this time the outcome promises to 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, 56, will give them an opportunity to safeguard economic and political power they see as jeopardized by the lifting of sanctions and opening to foreign investment.
During weeks of campaigning the two main candidates exchanged accusations of graft and brutality in unprecedentedly hostile television debates. Both deny the other's accusations.
Some 350,000 members of the security forces were deployed around the country to protect the election, state television reported. The interior ministry said at mid-day that it had no reports of electoral offences so far, state television reported.
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 favor 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.
Many pro-reform voters are still lukewarm Rouhani supporters, disappointed with the slow pace of change 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 shop keeper near the Imam Reza Shrine in the holy city of Mashhad, Raisi's home town.
In public, Khamenei has remained neutral, repeatedly calling for a high turnout. But Iranians in both political camps suspect he is in fact backing his protege Raisi -- not only for the presidency but potentially also as a possible successor to his own post of supreme leader, which the 77-year-old hardline cleric has held since 1989.
Despite the removal of nuclear-related sanctions in 2016, lingering unilateral U.S. sanctions that target Iran's record on human rights and terrorism have kept foreign companies wary of investing in Iran, 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 resonate with millions of poor voters angry at the Tehran elite.
Two other conservative candidates are still officially in the race. If no candidate wins more than 50 percent of the vote, the top two, presumably Rouhani and Raisi, would face each other a second time in a run-off in a week.
Polls close at 6 p.m. (1330 GMT), although authorities often extend voting into the evening. Ballot counting will start at midnight and final results are expected within 24 hours of polls closing, TV reported. The elections are also for city and village councils.