Magufuli stood unopposed after former Foreign Affairs Minister Bernard Membe, who planned to challenge the incumbent leader, was expelled earlier this year for unspecified ethical misconduct, a decision endorsed by the party on Friday.
Membe has denied any wrongdoing and has said he was kicked out of the party for wanting to run for president.
All 1,822 delegates at Chama Cha Mapinduzi’s national congress in the capital Dodoma voted in favor of Magafuli’s candidacy.
The congress was televised live by state television. Magufuli said he would retain the country’s first female Vice President Samia Suluhu Hassan as his running mate.
The ruling party also nominated Defense Minister Hussein Mwinyi as its presidential candidate for the Indian Ocean archipelago of Zanzibar, a semi-autonomous part of Tanzania, which holds separate elections at the same time as the mainland’s vote.
Since coming to power in late 2015, Magufuli, 60, has boosted government revenue, moved to reform the mining industry and increased spending on roads, railways and power projects.
Opposition leaders have accused the president of cracking down on democracy, freedoms and dissent, allegations that Mugufuli denies.