Some reports say the death toll could be high as 40 but officials have not confirmed this.
Tens of thousands of people had turned up at a stadium in Dar es Salaam to view the body of the former president.
Nicknamed the bulldozer, Mr Magufuli was popular with many Tanzanians for his no-nonsense governance style.
Critics, however, accused him of being an autocrat and of clamping down on dissent.