Ebrahim Raisi, who died aged 63, rose through Iran's theocracy from hardline prosecutor to uncompromising president, overseeing a crackdown on protests at home and pushing hard in nuclear talks with world powers as he burnished his credentials to position himself to become the next supreme leader.
Raisi died when a helicopter carrying him back from a visit to the Azerbaijani border crashed in mountainous terrain, killing all aboard, a senior Iranian official said. Foreign Minister Hossein Amirabdollahian was among those killed.
Elected president in a closely controlled vote in 2021, Raisi took a tough stance in the nuclear negotiations, seeing a chance to win broad relief from US sanctions in return for only modest curbs on Iran's increasingly advanced technology.
Iran's hardliners had been emboldened by the chaotic US military withdrawal from neighbouring Afghanistan and policy swings in Washington.
In 2018, then-US president Donald Trump had reneged on the deal Tehran had made with the six powers and restored harsh US sanctions on Iran, prompting Tehran to progressively violate the agreement's nuclear limits.
Indirect talks between Tehran and US President Joe Biden's administration to revive the deal have stalled.
Raisi's hardline position was also evident in domestic politics. A year after his election, the mid-ranking cleric ordered tighter enforcement of Iran's "hijab and chastity law" restricting women's dress and behaviour.
Within weeks, a young Kurdish Iranian woman, Mahsa Amini, died in custody after being arrested by morality police for allegedly violating that law.
The resulting months of nationwide protests presented one of the gravest challenges to Iran's clerical rulers since the 1979 Islamic Revolution.
Hundreds of people were killed, according to rights groups, including dozens of security personnel who were part of a fierce crackdown on the demonstrators. "Acts of chaos are unacceptable," the president insisted.
Although a political novice, Raisi had full backing for the nuclear stance and the security crackdown from his patron, the strongly anti-Western Supreme Leader Ayatollah Ali Khamenei.
Khamenei, rather than the president, has the final say in all major policies under Iran's dual political system, split between the clerical establishment and the government.
But Raisi's election victory, after heavyweight conservative and moderate rivals were disqualified by a hardline oversight body, brought all branches of power in Iran under the control of hardliners loyal to Khamenei and bolstered Raisi's chances of one day succeeding him as Supreme Leader.
However, the widespread protests against clerical rule and a failure to turn around Iran's struggling economy - hamstrung by Western sanctions and mismanagement - may have diminished his popularity at home.
'Pillar of the system'
As a young prosecutor in Tehran, Raisi sat on a panel that oversaw the execution of hundreds of political prisoners in the Iranian capital in 1988, as Iran's eight-year war with Iraq was coming to an end, rights groups say.
Inquisitions known as "death committees" were set up across Iran comprising religious judges, prosecutors and intelligence ministry officials to decide the fate of thousands of detainees in arbitrary trials that lasted just a few minutes, according to a report by Amnesty International.
While the number of people killed across Iran was never confirmed, Amnesty said minimum estimates put it at 5,000.
Asked about allegations that he had played a part in the death sentences, Raisi told reporters in 2021: "If a judge, a prosecutor, has defended the security of the people, he should be praised ... I am proud to have defended human rights in every position I have held so far."
He rose through the ranks of Iran's Shi'ite Muslim clergy and was appointed by Khamenei to the high-profile job of judiciary chief in 2019. Shortly afterwards, he was also elected deputy chairman of the Assembly of Experts, the 88-member clerical body responsible for electing the next Supreme Leader.
"Raisi is a pillar of a system that jails, tortures and kills people for daring to criticize state policies," said Hadi Ghaemi, executive director of New York-based advocacy group the Center for Human Rights in Iran (CHRI). Iran denies torturing prisoners.
Raisi shares with Khamenei a deep suspicion of the West. An anti-corruption populist, he backs Khamenei's self-sufficiency drive in the economy and his strategy of supporting proxy forces across the Middle East.
When a missile attack killed senior Iranian Revolutionary Guard officers in Iran's embassy in Damascus in April, Iran responded with an unprecedented but largely unsuccessful direct aerial bombardment of Israel.
Raisi said that any Israeli retaliation against Iranian territory could result in there being nothing left of the "Zionist regime".
"Raisi is someone that Khamenei trusts," said Sanam Vakil, deputy director of Chatham House’s Middle East and North Africa Program. "Raisi can protect the supreme leader's legacy.
Raisi served as deputy head of the judiciary for 10 years before being appointed prosecutor-general in 2014. Five years later, the United States imposed sanctions on him for human rights violations, including the 1980s executions.
Seeking the presidency, Raisi lost to the pragmatist Hassan Rouhani in a 2017 election. His failure was widely attributed to an audio tape dating from 1988 that surfaced in 2016 and purportedly highlighted his role in the 1988 executions.
In the recording, the late Ayatollah Hossein Ali Montazeri, then deputy supreme leader, spoke of the killings. Montazeri’s son was arrested and jailed for releasing the tape.
Raisi was born in 1960 to a religious family in Iran's holy Shi'ite Muslim city of Mashhad. He lost his father at the age of 5, but followed in his footsteps to become a cleric.
As a young student at a religious seminary in the holy city of Qom, Raisi took part in protests against the Western-backed Shah in the 1979 revolution. Later, his contacts with religious leaders in Qom made him a trusted figure in the judiciary.