Hardliner Ebrahim Raisi has won Iran's presidential election in a race that was widely seen as being designed to favour him.
He thanked Iranians for their support, after securing 62% of the votes.
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 be inaugurated in early August, and 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.
Iran is run according to conservative Shia Islamic 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. Official figures showed voter turnout was the lowest ever for a presidential election, at 48.8%, compared to more than 70% for the previous vote in 2017.
Who is Ebrahim Raisi?
The 60-year-old cleric has served as a prosecutor for most of his career. From an early age, Mr Raisi held powerful and high-ranking positions - when he was just 20 years old, he was already serving as the chief prosecutor of the city of Karaj.
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 inequality, and solve Iran's economic problems. "Our people's grievances over shortcomings are real," he said as he cast his vote in Tehran.
The man who wears a black turban identifying him in Shia tradition as a descendant of the Prophet Muhammad is fiercely loyal to Iran's ruling clerics, and has even been seen as a possible successor to Ayatollah Khamenei.
But many Iranians and rights groups have pointed to Mr Raisi's alleged role in the mass executions of political prisoners in 1988, when he was 27 years old.
He is said to have been part of a so-called "death committee" - one of four judges who oversaw secret death sentences for about 5,000 prisoners in jails near Tehran, according to Amnesty International. It says the location of the mass graves where the men and women were buried is being "systematically concealed by the Iranian authorities".
"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.
Mr Raisi has repeatedly denied his role in the death sentences. But he has also said they were justified because of a fatwa, or religious ruling, by former supreme leader Ayatollah Khomeini.
Amnesty also says that as head of the judiciary Mr Raisi oversaw impunity for officials and security forces accused of killing protesters during unrest in 2019.
What does his win mean for Iran and the world?
Mr Raisi has promised to ease unemployment and work to remove US sanctions that have contributed to economic hardship for ordinary Iranians and caused widespread discontent.
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 put under sanctions.
Iran has responded by re-starting nuclear operations that were banned under the deal.
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.
Iran will be a more closed society
Analysis by Kasra Naji, BBC Persian
The election was engineered to pave the way for Mr Raisi to win. This has alienated a good number of Iranians already deeply discontented with their living conditions in an economy that is crippled by US sanctions but also mismanagement.
The result of the election will not help with their concerns and may even lead to more instability at home. In the past few years Iran has witnessed at least two rounds of serious nationwide protests - with hundreds, some say thousands, killed.
With Mr Raisi taking the presidency the hardliners will have taken all the centres of power: the executive branch as well as the legislative and the judiciary. Iran will be a more closed society. Freedoms will likely be curtailed even more than before.
The regime will look to China to help the economy out of deep crisis. There will be more tension with the West. Indirect talks between Iran and the US in Vienna over reviving the nuclear deal may face more uncertainty. There are already reports that the talks will now break up for a few weeks, allowing all sides to take stock of the new reality in Iran.
Was the election free?
Almost 600 hopefuls, including 40 women, registered to be candidates in the election.
But in the end only seven men were approved last month by the 12 jurists and theologians on the 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.
Before he withdrew, reformist candidate Mohsen Mehralizadeh hinted that the vote would be a foregone conclusion, saying during a candidates' TV debate that the ruling clerics had aligned "sun, moon and the heavens to make one particular person the president," according to The Economist.
Meanwhile former President Mahmoud Ahmadinejad, one of those barred from running, said in a video message that he would not vote, declaring: "I do not want to have a part in this sin."