TEHRAN, Iran (AP) — Hundreds of thousands mourned former Iranian President Akbar Hashemi Rafsanjani on Tuesday, wailing in grief as his body was interred at a Tehran shrine alongside the leader of the country's 1979 Islamic Revolution.
Rafsanjani's final resting place near the late Supreme Leader, Ayatollah Ruhollah Khomeini, reflected his legacy as one of the pillars of Iran's clerical-dominated political system, as he served in later years as a go-between for hard-liners and reformists.
But even his hourslong funeral highlighted the divisions still at play. Parts of the crowd along his funeral procession at one point chanted in support of opposition leaders under house arrest. Other politicians did not attend the memorial.
Throngs filled main thoroughfares of the capital, with many chanting, beating their chests and wailing in the style of mourning common among Shiite Muslims.
The funeral for Rafsanjani, who died Sunday at age 82 after a heart attack, drew both the elite and ordinary people. Shops and schools were closed in national mourning.
Top government and clerical officials first held a funeral service at Tehran University. Iran's Supreme Leader Ayatollah Ali Khamenei prayed by Rafsanjani's casket, as other dignitaries knelt before the coffin on which his white cleric's turban was placed. Mourners reached out their hands toward the coffin.
Just behind Khamenei was President Hassan Rouhani, whose moderate administration reached the recent nuclear deal with world powers. Rouhani, who is all but certain to run for re-election in May, is viewed as embodying Rafsanjani's realist vision.
Hard-liners also took part in the ceremony Tuesday, like the head of Iran's judiciary, Sadeq Larijani, who stood near his moderate brother, parliament speaker Ali Larijani.
Also among them was Qassem Soleimani, a general who heads the Revolutionary Guard's elite Quds Force, which focuses on foreign operations like the war in Syria.
Both Soleimani and Rafsanjani are from Iran's southeastern province of Kerman and worked together during the war with Iraq in the 1980s.
"In my opinion, Mr. Hashemi remained the same person from the beginning until the end and held his line in all stages of his life," Soleimani told state television in a rare public interview. "Nevertheless, Mr. Hashemi sometimes used different tactics."
Apparently banned from the funeral was former Iranian President Mohammad Khatami, a reformist who remains popular among the young but is deeply disliked by hard-liners. State media have banned the broadcasting of any images of Khatami.
There was also no word of hard-line former President Mahmoud Ahmadinejad attending the ceremony, though he offered condolences Monday. There was no love lost between the two as Ahmadinejad defeated Rafsanjani in Iran's 2005 presidential election and later drew his dismay over the crackdown following his contested re-election in 2009.
Outside, mourners carried posters bearing Rafsanjani's image as his casket slowly made his way through the crowds in the streets.
"I rarely attend religious ceremonies, but I am here as an Iranian who cannot forget Rafsanjani's contribution to developing the political sphere in favor of people in recent years," said Nima Sheikhi, a computer teacher at a private school.
"I am here to say goodbye to a man who dedicated his life to making Iran better," said Reza Babaei, a cleric from the eastern town of Birjand near the Afghan border. "He founded the university in my city and developed our region when he was in power."
Officials put the number of participants in the funeral at over 2 million, though that figure could not be independently verified.
Iran's internal politics also were on display. The semi-official ILNA news agency said that on the sidelines of the funeral, prominent moderate lawmaker Ali Motahari was asked by several mourners to free opposition leaders Mir Hossein Mousavi and Mahdi Karroubi from the house arrest the two have been under since 2011.
"Our message is clear: The house arrest should be lifted," some chanted. Police and security forces did not react to the chants, nor others that followed and could be heard in state television footage.
Rafsanjani's casket later arrived at the ornate, massive shrine to Khomeini, who led the revolution that toppled the American-backed shah.
Rafsanjani's interment there marked a rare privilege inside of Iran's system, where clerics dominate the levers of power. Only Khomeini's son Ahmad, who died in 1995 and served as a close aide to his father, had been buried next to his tomb before Tuesday.
Rafsanjani, a close aide to both Khomeini and Khamenei, served as president from 1989 to 1997. He helped launch Iran's nuclear program and then pushed for reconciliation with the West.
Internally, however, his legacy remains mixed. He was massively wealthy and a veteran at maneuvering within Iran's opaque political system.
He was considered a protector of the moderates, but others distrusted him because he was such an insider and because of accusations he was involved in killing dissidents during his eight-year presidency, which he always denied. Hard-liners distrusted him because of his support of moderates and sought to sideline him, with little success.
His absence in balancing the competing powers, however, will affect Iran going forward, especially as the country edges closer to picking a new supreme leader.
"The unexpected death of Akbar Hashemi Rafsanjani could be the first scene in Iran's nascent leadership transition theater, whose subsequent acts are probably yet to be written," said Mehdi Khalaji, a fellow at The Washington Institute.
Gambrell reported from Dubai, United Arab Emirates.