Mourners gather around a hearse carrying the coffin of former president Akbar Hashemi Rafsanjani during his funeral ceremony in the capital Tehran on January 10, 2017
Tehran (AFP) - Hundreds of thousands of mourners attended the funeral on Tuesday of Iran's ex-president Akbar Hashemi Rafsanjani, whose death leaves a hole in the upper reaches of power for the country's moderates.
It took more than two hours for the cortege to make its way through the crowds to the south Tehran mausoleum where Rafsanjani was laid to rest.
Tehran city officials estimated that at least two-and-a-half million people took to the streets to bid farewell, which would make it the largest funeral attendance since the death of the Islamic revolution's founder Ayatollah Ruhollah Khomeini in 1989.
Pallbearers accidentally knocked the former president's trademark white turban off the coffin as they carried it into the burial chamber at Khomeini's mausoleum.
Rafsanjani, who served as president from 1989 to 1997, was a father figure for Iran's moderate and reformist camps.
His death is a blow for President Hassan Rouhani, whose 2013 election was largely due to Rafsanjani's support.
Rouhani, who spearheaded the thaw with the West that culminated in a 2015 nuclear deal, faces a tough re-election battle in May amid disappointment over the smaller than anticipated economic dividends of the lifting of international sanctions.
Supreme leader Ayatollah Ali Khamenei led the eulogies to Rafsanjani at Tehran University despite their "differences".
Rafsanjani fell out of the regime's highest inner circle following the 2009 re-election of hardliner Mahmoud Ahmadinejad, when he spoke out against the use of lethal force on protesters who claimed the vote was rigged.
Rouhani attended the funeral but so too did his conservative rivals, parliament speaker Ali Larijani, and his brother, judiciary chief Ayatollah Sadegh Larijani.
One of Iran's most controversial figures in the West, the head of the elite Revolutionary Guards' foreign operations division, Major General Qassem Suleimani, also attended.
Tehran prayer leader Ayatollah Mohammad Emami Kashani passed out and had to be treated at the scene by Health Minister Hassan Ghazizadeh Hashemi, an ophthalmologist by training, Iranian media reported.
Reformist former president Mohammad Khatami, an ally of Rafsanjani but long out of favour with the regime, was not part of the official delegation.
Some Twitter users said he had been prevented from attending.
- 'Hail Khatami' -
State television coverage of the funeral procession captured a few seconds of chants of "Hail Hashemi (Rafsanjani), hail Khatami," before the broadcaster drowned it out with solemn music.
Video clips published on social media showed pockets of mourners in the streets chanting slogans in support of both Khatami and fellow reformist Mir Hossein Mousavi.
Mousavi and Mehdi Karoubi, two of the losing candidates in the 2009 election, have been under house arrest since 2011 for leading the so-called Green Movement protests that the regime calls "sedition".
Khatami is under a strict media ban and is often prevented from attending public events.
Rafsanjani's family thanked people for their support after the procession.
"As every moment of Hashemi's life helped the country find its path, the impressive farewell of people to him can... point the return of society to the path of moderation and unity," it said in a statement quoted by the Tabnak website.
Black banners were raised in Tehran and some posters showed the supreme leader and Rafsanjani together smiling. Another poster said "good bye, old combatant".
Since Rafsanjani's death, messages of condolence have poured in both from at home and abroad.
Even the White House sent a message, unprecedented since the 1979 revolution that led to cutting of ties between Tehran and Washington.
"Former president Rafsanjani was a prominent figure throughout the history of the Islamic Republic of Iran and the United States sends our condolences to his family and loved ones," spokesman Josh Ernest said.
"He was a consequential figure inside Iran. But you know, for what potential impact this could have on Iranian policy, I wouldn't speculate."
Tuesday was declared a public holiday in Iran and all public transport in Tehran was free for the day.
Rafsanjani headed the Expediency Council, a key advisory and arbitration body.
Khamenei must now appoint a successor and his choice will go a long way towards determining Rouhani's room for manoeuvre in the face of state institutions that are dominated by conservatives.