Mr Magufuli had first been admitted to the Jakaya Kikwete Cardiac Institute on March 6, but later was discharged, Ms Hassan said on state television.
However, he was taken urgently to hospital again on March 14 after feeling unwell.
Opposition leader Zitto Kabwe said on Twitter: “The nation will remember him for his contribution to the development of our country.”
British Prime Minister Boris Johnson offered his condolences on Twitter, writing: “I’m sorry to hear that @MagufuliJP, President of Tanzania, has passed away.
“My thoughts are with his loved ones and the people of Tanzania.”