Reformist Masoud Pezeshkian has been elected as Iran’s new president, beating his hardline conservative rival Saeed Jalili.
The vote was declared in Dr Pezeshkian’s favour after he secured 53.3% of the more than 30 million votes counted. Mr Jalili polled at 44.3%.
The run-off came after no candidate secured a majority in the first round of the election on 28 June, which saw a historically low voter turnout of 40%.
The election was called after Iran’s previous president Ebrahim Raisi was killed in a helicopter crash in May, in which seven others also died.
The leaders of China, India and Russia have all congratulated Dr Pezeshkian on his victory.
Even before the final results were declared by Iran’s interior ministry, Dr Pezeshkian’s supporters had taken to the streets in Tehran and a number of other cities to celebrate.
Videos posted on social media showed mostly young people dancing and waving the signature green flag of his campaign, while passing cars sounded their horns.
Dr Pezeshkian, a 71-year-old heart surgeon and member of the Iranian parliament, is critical of Iran’s notorious morality police and caused a stir after promising “unity and cohesion”, as well as an end to Iran’s “isolation” from the world.
He has also called for “constructive negotiations” with Western powers over a renewal of the faltering 2015 nuclear deal in which Iran agreed to curb its nuclear programme in return for an easing of Western sanctions.
His rival, Saeed Jalili, favours the status quo. The former nuclear negotiator enjoys strong support amongst Iran’s most religious communities.
Mr Jalili is known for his hardline anti-Western stance and opposition to restoring the nuclear deal, which he says crossed Iran’s “red lines”.
Turnout in the latest round of voting was 50% – higher than the first round last week, when the turnout was the lowest since the Islamic revolution in 1979 amid widespread discontent, but still considerably low.
Widespread discontent meant that millions of people boycotted the elections.
Lack of choice in the candidates, dominated by Islamic hard liners, and the impossibility of real change as long as the supreme leader tightly controls policies added to their frustration.
Some people who did not vote in the first round were persuaded to cast their ballot for Dr Pezeshkian this time round to prevent Mr Jalili from becoming the president.
They feared that if he won, Iran would be heading for more confrontation with the outside world and that he would bring Iran more sanctions and further isolation.
In order to stand, both candidates had to make it through a vetting process run by the Guardian Council, a body made up of 12 clerics and jurists that hold significant power in Iran.
That process saw 74 other candidates removed from the race, including several women.
The Guardian Council has previously been criticised by human rights groups for disqualifying candidates who are not loyal enough to the regime.