Hardliner Ebrahim Raisi is to be Iran's next president after a partial vote count gave him an unassailable lead.
He beat three other candidates in a poll in which several contenders 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.
The president has significant influence over domestic policy and foreign affairs. But it is Supreme Leader Ayatollah Ali Khamenei who has the final say on all state matters.
Iran's hardliners oppose greater social freedoms and are suspicious of the West, although some favour of a return to an international deal on Iran's nuclear activity.
The US pulled out of the existing deal, the Joint Comprehensive Plan of Action, in 2018.
President Trump's administration reimposed crippling sanctions on Iran after withdrawing. The sanctions have contributed to economic hardship for ordinary Iranians, which has caused widespread discontent.
Talks aimed at resurrecting the deal are ongoing in Vienna.
What is the election result so far?
Mr Raisi's three rivals and outgoing President Hassan Rouhani have all congratulated him on his victory.
With counting continuing, state TV said Mr Raisi had so far received 62% of the vote - nearly 18 million of more than 28 million votes cast. Some 59 million Iranians were eligible to vote.
Almost 600 hopefuls, including 40 women, registered for the election.
But in the end only seven men were approved last month by the 12 jurists and theologians on the hardline Guardian Council, an unelected body that has the ultimate decision with regard to candidates' qualifications. Three of those candidates subsequently pulled out before polling day.
media captionIran elections: To vote or not to vote?
Who is Ebrahim Raisi?
The 60-year-old cleric has served as a prosecutor for most of his career. He was appointed judiciary chief in 2019, two years after he lost by a landslide to Mr Rouhani in the last election.
Mr Raisi has presented himself as the best person to fight corruption and solve Iran's economic problems.
However, many Iranians and human rights activists have expressed concern over his role in the mass executions of political prisoners in the 1980s.