Iran began three days of mourning Monday after the death of ex-president Akbar Hashemi Rafsanjani, a pillar of the Islamic revolution who became a leading counterweight to hardliners.
Tributes poured in for the moderate cleric, including from President Hassan Rouhani, who was reportedly at Rafsanjani's bedside before he died of a heart attack aged 82.
"Islam lost a valuable treasure, Iran an outstanding general, the Islamic revolution a courageous flag-bearer and the Islamic system a rare sage," Rouhani said.
Iran's political and religious leadership attended a memorial service at Hussainiya Jamaran, a religious hall in northern Tehran run by the family of Ayatollah Ruhollah Khomeini, the founder of the Islamic republic.
Rafsanjani, who after serving for two terms became a cautious reformist to offset the hardliners clustered around a successor, Mahmoud Ahmadinejad, will be buried Tuesday at Khomenei's mausoleum in southern Tehran.
The ISNA news agency said his death Sunday was a "great loss for the moderates," describing the ayatollah as "the sheikh of moderation".
Rafsanjani was a key backer of Rouhani and supported Iran's landmark nuclear deal with world powers.
Rouhani is expected to stand for a second four-year term in a May vote and has now lost a key supporter in the crucial run-up to the election.
- Black banners -
The front pages of Monday's newspapers were dominated by the face of Rafsanjani, who served as president from 1989 to 1997, and black banners were raised on Tehran's streets.
All music concerts and television comedy programmes were called off as a sign of respect.
At Monday's memorial service, student Ali Tafreshi said he cried for three and half hours after he heard Rafsanjani had died.
"This cannot be compensated. We have no one like him, as the supreme leader said. A pillar is missing from the revolution's building," he said.
Rafsanjani's youngest son Yaser, 46, thanked people mourning his father for their "loyalty and kindness".
"I see scenes of affection that I cannot believe. People's prayers for our father console our hearts," he told state television.
Signup to our newsletter and follow us on Facebook and Twitter!
Rafsanjani was born on August 25, 1934 in southern Iran to the family of a wealthy pistachio farmer.
He studied theology in the holy city of Qom before entering politics in 1963 after the shah's police arrested Khomeini.
A confidant of Khomeini, Rafsanjani was the speaker of parliament for two consecutive terms until Khomeini's death in 1989.
Rafsanjani's presidency, a breathing space after the end of the 1980-88 Iran-Iraq war, was marked by reconstruction, cautious reform and repairs to Iran's relations with its Arab neighbours.
But it was also marred by human rights violations, rampant inflation and difficult relations with Europe, not least with Britain after the "death sentence", or fatwa, handed down to writer Salman Rushdie by Khomeini.
- 'I can die in peace' -
Supreme leader Ayatollah Ali Khamenei is expected to lead special Islamic prayers performed for the deceased during Tuesday's funeral service.
State television on Monday looped old interviews by Rafsanjani and Khamenei, emphasising the lasting bond between two stalwarts of the 1979 revolution.
Rafsanjani was always a member of Iran's top clerical body, the Assembly of Experts, charged with appointing -- and if required dismissing -- the country's supreme leader. He chaired the influential committee for several years.
The ayatollah played an important role in the election of the reformist Mohammad Khatami, who succeeded him as president from 1997 to 2005.
Rafsanjani suffered a big blow when he lost in the presidential vote's second round to hardline Ahmadinejad in 2005.
But he rose again, this time more determined in helping the reformist and moderate camps defeat ultra-conservatives, under whom Iran's relations with the West plummeted.
In the run-up to the presidential elections in 2013, hand in hand with Khatami, the two figures played a key role in uniting and organising people in favour of the moderate Rouhani, who could not have secured the office without reformist support.
In an interview last year Rafsanjani recounted events leading to the end if Ahmadinejad's reign.
"I succeeded in partially changing the situation under the worst circumstances. People won in 2013, as bravely as they started the revolution," he told the reformist Shargh daily.
"I can die in peace now, as people make their own choices."