Iran's ex-President Akbar Hashemi Rafsanjani, a dominant figure in the country's politics since the 1980s, has died at the age of 82.
Mr Rafsanjani, president from 1989 to 1997, suffered a heart attack.
He played a pivotal role in the 1979 revolution but later in life became a counterpoint to hardline conservatives.
Supreme Leader Ali Khamenei hailed a "companion of struggle" despite their differences, saying that the loss was "difficult and overwhelming".
"The different opinions and interpretations at time in this long period could never entirely break up the friendship" between us, Ayatollah Khamenei said.
There will be three days of national mourning and a funeral in Tehran is due on Tuesday, which has been declared a public holiday.
Mr Rafsanjani was admitted to the Shohadaa Hospital in Tehran on Sunday, where doctors tried unsuccessfully for an hour to save him, media said.
A TV broadcaster broke into programmes to bring the news, saying Mr Rafsanjani "after a life full of restless efforts in the path of Islam and revolution, had departed for lofty heaven".
Mr Rafsanjani had warm relations with President Hassan Rouhani, who was seen at the hospital shortly before the death was announced. A crowd reportedly gathered at the hospital later to mourn.
In a tweet, the president said: "The soul of the great man of the Revolution, symbol of patience and resistance, has gone to Heaven."
The BBC's Kasra Naji says Mr Rafsanjani was a great survivor of the Iranian revolution, always managing to stay afloat in the unending political struggles between the hardliners and the moderates, always remaining influential.
In recent years, our correspondent says, he has been a central figure in the reform movement that has been trying to have a moderating influence on Iran and Ayatollah Khamenei.
He has been a mentor to President Rouhani, whom he supported after his own attempt to run in the 2013 election as a reformist candidate was rejected by the powerful Guardian Council.
Mr Rafsanjani's final role was head of the Expediency Council, which tries to resolve disputes between parliament and the Guardian Council.
A US state department official described him as a "prominent figure" throughout the history of the Islamic Republic of Iran.
Blow to reformists? Parham Pourparsa, BBC Monitoring
The sudden death of the veteran pragmatist politician will be a major blow to President Rouhani. The president, who is preparing himself for re-election in May, has lost a valuable ally and influential figure who was a founding father of the Islamic Republic.
This explains why Mr Rouhani was the first top official to attend the hospital where Mr Rafsanjani died. Reports say Mr Rouhani was in tears.
Since the 2013 presidential election, Mr Rafsanjani has fully backed Mr Rouhani. Mr Rafsanjani was also a staunch supporter of the landmark 2015 nuclear deal with world powers.
But in Iran's complicated political landscape, his death could also mobilise pro-Rouhani moderates and reformists ahead of the election.
Akbar Hashemi Rafsanjani was born in 1934 in south-eastern Iran to a family of farmers.
He studied theology in the holy city of Qom with Ayatollah Ruhollah Khomeini - who went on to lead the Islamic revolution of 1979 - and was imprisoned several times under the Shah.
In the last year of the 1980-88 war with Iraq, Ayatollah Khomeini appointed him acting commander-in-chief of the armed forces.
He was seen as the main mover behind Iran's acceptance of the UN Security Council resolution that ended the war.
Mr Rafsanjani was also a key player in the development of Iran's nuclear programme.
He was a man known for a sharp wit but who could also be ruthless.
He advocated progressive economic policies, encouraging private businesses and improving infrastructure. His own business holdings were reported to be widespread.
Mr Rafsanjani ran for a third time for president in 2005 but lost to Mahmoud Ahmadinejad.
Mr Rafsanjani became openly critical of the victorious president and in 2009, he sided with reformers who disputed that year's elections. Nevertheless, Mr Ahmadinejad won a second term.
Mr Rafsanjani continued to champion moderate causes, such as the release of political prisoners and greater political freedoms for parties prepared to work within the constitution.
Some of the members of Mr Rafsanjani's family have also made the headlines. His daughter, Faezeh Hashemi, attracted the ire of hardliners when she met a leader of the Bahai religious minority - which Iran's leadership regards as a heretical sect - last year.
And his son, Mehdi Hashemi Rafsanjani, was jailed in 2015 after being convicted of "security offences and financial crimes".