Polls opened in Iran on Friday with voters set to give their verdict on President Hassan Rouhani's policy of opening up to the world and efforts to rebuild the stagnant economy.
He faces stiff competition from hardline cleric Ebrahim Raisi, 56, who has positioned himself as a defender of the poor and called for a much tougher line with the West.
Supreme leader Ayatollah Ali Khamenei cast his ballot just minutes after polls opened at 8:00 am (0330 GMT).
"The destiny of the country is in the hand of Iranians," he told reporters as he voted in his compound in Tehran.
Long lines had already formed at polling stations around the country.
Rouhani, a 68-year-old moderate cleric, has sought to frame the election as a choice between greater civil liberties and "extremism".
He has pushed the boundaries over the past fortnight, criticising the continued arrest of reformist leaders and activists, and calling on security agencies not to interfere in the vote.
Raisi says he will stick by the 2015 nuclear deal with world powers, that saw curbs to Iran's atomic programme in exchange for sanctions relief, but he points to the continued economic slump as proof that Rouhani's diplomatic efforts have failed.
"Instead of using the capable hands of our youths to resolve problems, they are putting our economy in the hands of foreigners," Raisi said at a final rally in the holy city of Mashhad on Wednesday.
Rouhani responded by calling on voters to keep hardliners away from Iran's delicate diplomatic levers.
"One wrong decision by the president can mean war and a correct decision can mean peace," he said at his own Mashhad rally.
The election comes at a tense moment in US-Iran relations.
Rouhani gained a reprieve on Wednesday when the administration of US President Donald Trump agreed to continue waiving nuclear-related sanctions, keeping the deal on track for now.
But Trump has launched a 90-day review of the accord that could see it abandoned, and is visiting Iran's bitter regional rival Saudi Arabia this weekend.
- Economic slump -
"For me, Mr Rouhani's dialogue with the world and moderation in society are very important," said Zahra, a 32-year-old PhD student in food science.
Under former hardline president Mahmoud Ahmadinejad, "the sanctions really hurt us. It was hard to get lab equipment and very difficult to get visas to study abroad. Now my colleagues can travel to France and the US," she said.
Despite the global implications, it is the economy that has dominated the campaign.
Rouhani has brought inflation down from around 40 percent when he took over in 2013, but prices are still rising by nine percent a year.
Oil sales have rebounded since the nuclear deal took effect in January 2016, but growth in the rest of the economy has been limited, leaving unemployment at 12.5 percent overall, and almost 30 percent for young people.
Rouhani has vowed to work towards the removal of remaining US sanctions that are stifling trade and investment deals with Europe and Asia, but he is unlikely to receive much assistance from Trump.
Raisi has instead promised to triple cash hand-outs to the poor, hoping to pick up voters that once supported Ahmadinejad.
Having proved too independent for the conservative establishment, Ahmadinejad was dramatically barred from standing by the Guardian Council last month as it disqualified all but six of the 1,636 people who signed up for the election.
The presidential race has since narrowed to a two-horse race as other candidates either pulled out or called on their supporters to back Rouhani or Raisi.
Two other candidates are still technically standing -- conservative Mostafa Mirsalim and reformist Mostafa Hashemitaba -- though they are not expected to win more than a few percent of the vote.
Iranians are also voting for their local councils, with reformists particularly hoping to undo the conservatives' narrow majority in Tehran.