Iranians poured into polling stations on Friday to give their verdict on President Hassan Rouhani and his troubled efforts to rebuild ties with the world and kick-start the struggling economy.
It was a festive mood across Tehran on Friday as thousands lined up to vote, many coming with family and friends to debate and help each other navigate the complex choices.
There are no booths in Iranian polling stations, and voting often turns into a communal activity as people discuss their choices openly and help each other fill out the forms, which must be written by hand.
As well as picking a president between incumbent moderate Hassan Rouhani and hardliner Ebrahim Raisi, they also had to select 21 local councillors.
For the first time, Iranians rushed to the polls early in the morning, saying they were keen to encourage as high a turnout as possible.
"We came early to encourage others to come. We've taken pictures of ourselves and put them on social media," said Mansoureh, a 45-year-old university lecturer.
Many carried lists of councillors advised by reformists or conservatives on their mobiles and helped elderly people fill out their ballots.
A group of women, with the loose and colourful headscarves of more liberal Tehranis, searched for Rouhani's code on the board, lost among the posters for the 2,700 council candidates.
Some were dressed up for the occasion, with one man looking particularly dapper in bow tie and dinner jacket, while a newly married woman even showed up in her wedding dress.
At one of the biggest mosques, the Hosseinieh Ershad, a friendly debate was going on between an elderly Rouhani supporter and a young clerical student backing Raisi.
"Outside Tehran, people are having a really difficult time, and our foreign policy should have more authority," said the cleric, a 20-year-old called Morteza.
The elderly man politely responded that Rouhani was right to cut back on subsidies, fix the country's finances and invest in infrastructure.
Nearby, a woman scolded another voter in line for wearing purple, which was Rouhani's campaign colour.
"This is very bad. You are telling people who you are voting for -- they could invalidate all our votes from here!" she cried.
A distinction exists, it seems, between discussing your ballot with friends and advertising your choice to the world.
Sydney's Iranian community vote in the election
"Instead of using the capable hands of our young people to resolve problems, they are putting our economy in the hands of foreigners," he said at a closing campaign rally in second city Mashhad on Wednesday.
He has targeted working-class voters hit by high unemployment and subsidy cuts, as well as those who worry the values of the 1979 revolution are under threat.
"I think the most important factors are the ones we had a revolution for, like establishing social justice and removing poverty," said 23-year-old engineering student Mohammad Ali Serkani at a polling station in Tehran.
"I voted Raisi because the Rouhani government and the nuclear deal stopped a lot of research in scientific fields such as nuclear, missile and space technology," he added.
Rouhani has warned that hardliners must be kept away from Iran's diplomatic levers at a delicate moment in relations with the United States.
"One wrong decision by the president can mean war," he said at his own Mashhad rally.
Rouhani gained a reprieve on Wednesday when Washington agreed to continue waiving nuclear-related sanctions, keeping the deal on track for now.
But US President Donald 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.
Supreme leader Ayatollah Ali Khamenei cast his vote at his compound in Tehran just minutes after polls opened, saying: "The destiny of the country is in the hands of Iranians."
Long queues formed at polling stations around the country after a short but gripping campaign that has again captivated the nation of 80 million.
"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 at another Tehran polling station.
Under Rouhani's predecessor, hardliner 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 office in 2013, but prices are still rising by nine percent a year.
Oil sales have rebounded since the nuclear deal took effect in January last year, 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.
Raisi has promised to triple cash handouts 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 hopefuls who registered.
The presidential race has since narrowed to a two-horse race as other candidates either pulled out or backed Rouhani or Raisi.
Iranians are also voting for local councils, with reformists hoping to topple the conservatives' narrow majority in the capital.
With the turnout looking far bigger than last year's parliamentary election, thousands joined a group on popular messaging app Telegram in a bid to locate polling stations with smaller queues.
At a Tehran school, excitement broke out when one of the candidates, reformist Mostafa Hashemitaba, showed up to vote, waiting politely in line.
In a sign of the oddities of the Iranian system, he voted for Rouhani and called on his supporters to do the same.
The Guardian Council allowed only six people to run in the election, of which four ended up operating as back-up for the main candidates.
Hamed Boroujerdi, 40, who owns a clothing store, took turns with his wife as they minded their two small children outside the school.
"We hope things don't get worse in terms of economy and politics so we voted Rouhani," he said.
Others were voting for the first time, including 51-year-old Amir Fathollahzadeh.
"I've almost lost my entire business in past years and now I want to vote Rouhani so at least I don't lose my dignity and pride," he told AFP.
He hopes Rouhani can build on his success in reducing sanctions on Iran so that he can more easily import phones and tablets.
But Mohammad Ali Serkani, 23, a student who voted Raisi along with his sister and parents, believed that protecting "Islamic culture and economy" were the most important factors.
At a nearby mosque, where men and women lined up in separate queues, there were many more Raisi supporters.
"I've always voted," said Mahanz Rafii, 50, a theology professor, wearing her head-to-toe chador robes.
"Unfortunately in recent years the dialogue of revolution has been weakened. People should restore the revolution's path."