In the teeming streets, scenes clashed incongruously. At one point, Ayatollah Khamenei could be heard through loudspeakers saying prayers for Mr. Rafsanjani while protesters chanted opposition slogans. Some wore green wristbands, the color of the opposition, and flashed victory signs.
Supporters of the establishment tried to drown out the slogans by shouting “Allahu akbar,” meaning “God is great,” but for the most part they were overmatched. On state television, sound engineers at one point forgot to lower the volume when people shouted, “Hail to Khatami.”
“Hashemi’s death is a great worry to us,” said Leili Farhang, a 26-year-old university graduate, who emphasized that she was unemployed “like many of my generation.” She and her friends had showed up in front of the Tehran University campus “to pay respect to a man who respected us.”
It was hard, she and her friends agreed, to come up with the name of anybody within Iran’s establishment to replace Mr. Rafsanjani. Not one has his weight and stature, they concluded: “He will be missed.”
It took hours for the body to arrive at the South Tehran mausoleum, because of “the millions that have come out to honor the ayatollah,” Khabarfori, an Iranian online news channel, said on the Telegram messaging app.
Inside the mausoleum, state television showed, a marching band played the national anthem, after which Mr. Rafsanjani’s coffin was placed next to Mr. Khomeini’s, as planned.