Soleimani was assassinated in a US drone strike in Iraq on Friday on the orders of President Donald Trump.
Iran’s supreme leader Ayatollah Khamenei led prayers and at one point was seen weeping.
Iran has vowed “severe revenge” for the death of Soleimani and on Sunday pulled back from the 2015 nuclear accord.
Soleimani, 62, spearheaded Iranian military operations in the Middle East, and was regarded as a terrorist by the US.
President Trump said Soleimani was plotting “imminent” attacks on US diplomats and military personnel in Iraq and elsewhere in the region.
What happened at Soleimani’s funeral?
State television showed huge crowds in Tehran for the event. Soleimani was hailed as a national hero and widely considered the second most powerful man in the country behind Supreme Leader Khamenei.
People cried while others clutched pictures of the late commander. Mourners passed his coffin over their heads and “death to America” chants were heard.
His daughter Zeinab Soleimani warned the US it faces a “dark day” for the killing. “Crazy Trump, don’t think that everything is over with my father’s martyrdom,” she said.