Tens of thousands of Iranians filled the streets of Tehran on Tuesday for the funeral procession of former President Akbar Hashemi Rafsanjani, as moderates grappled with how his death will affect a longtime ally’s chances of winning re-election as president in May.

The only declared candidate backed by conservatives has a low public profile and there are no official opinion polls to gauge popularity in Iran’s opaque electoral system. But Mr. Rafsanjani’s death deprived incumbent President Hassan Rouhani, who backed the 2015...