Hardliner Ebrahim Raisi is set to be Iran’s next president after winning most of the votes counted so far.
He beat three other candidates in a poll in which most would-be candidates were barred from standing.
Mr Raisi is Iran’s top judge and holds ultra-conservative views. He is under US sanctions and has been linked to past executions of political prisoners.
Iran’s president is the second-highest ranking official in the country, after the supreme leader.
Mr Raisi will have significant influence over domestic policy and foreign affairs. But in Iran’s political system it is the country’s supreme leader, Ayatollah Ali Khamenei, the top religious cleric, who has the final say on all state matters.
The country is run according to conservative religious values, and there have been curbs on political freedoms since its Islamic Revolution in 1979. Many Iranians saw this latest election as having been engineered for Mr Raisi to win, and shunned the poll.
Who is Ebrahim Raisi
The 60-year-old cleric has served as a prosecutor for most of his career. He was appointed head of the judiciary in 2019, two years after he lost by a landslide to Hassan Rouhani in the last presidential election.
Mr Raisi has presented himself as the best person to fight corruption and solve Iran’s economic problems. “Our people’s grievances over shortcomings are real,” he said as he cast his vote in Tehran.
He is fiercely loyal to Iran’s ruling clerics, and has even been seen as a possible successor to Ayatollah Khamenei as the country’s supreme leader.
Many Iranians and rights groups have pointed to Mr Raisi’s role in the mass executions of political prisoners in the 1980s. He was one of four judges who oversaw death sentences for about 5,000 prisoners, according to Amnesty International.
“That Ebrahim Raisi has risen to the presidency instead of being investigated for the crimes against humanity of murder, enforced disappearance and torture, is a grim reminder that impunity reigns supreme in Iran,” said Amnesty chief Agnès Callamard.
Iran has never acknowledged the mass executions and Mr Raisi has never addressed the allegations about his role in them.
BBC Persian correspondent Kasra Naji adds that under Mr Raisi Iran’s hardliners will seek to reinforce a puritanical system of Islamic government, possibly meaning more controls on social activities, fewer freedoms and jobs for women, and tighter control of social media and the press.
The hardliners are suspicious of the West, but both Mr Raisi and Supreme Leader Khamenei favour a return to an international deal on Iran’s nuclear activity.
The Joint Comprehensive Plan of Action, signed in 2015, gave Iran relief from Western sanctions in return for limiting its nuclear activities.
The US pulled out of the deal in 2018, and President Trump’s administration re-imposed crippling limits on Iran’s ability to trade. Mr Raisi was among the officials sanctioned.
Talks aimed at resurrecting the deal are ongoing in Vienna, with President Joe Biden also keen to revive it. But both sides say the other must make the first move.