Tanzania has threatened to arrest and expel activists, as well as de-register all non-governmental organizations that campaign for gay rights.

Homosexuality is a criminal offense in the East African nation, where the law states that suspects convicted of having "carnal knowledge of any person against the order of nature" could face up to 30 years in jail.

At a rally late on Sunday, Tanzania's Home Affairs Minister Mwigulu Nchemba said both domestic and foreign campaigners for gay rights would now face punitive measures in the country.

"Those who want to campaign for gay rights should find another country that allows those things," Nchemba said in the capital Dodoma. "If we establish that any organization registered in our country is campaigning for gay rights ... I will deregister that organization. If a Tanzanian national is doing that campaign, we will arrest him and take him to court ... and if it is a foreigner, we will immediately order him to leave the country."

The planned crackdown comes amid repeated warnings against "immoral behaviors" by President John Magufuli, who is nicknamed "the Bulldozer" for pushing through his policies.

Last week, he rejected calls to lift the decades-long ban on pregnant students from attending state schools, drawing criticism from rights groups.

Nchemba said Magufuli's decisions were final and non-negotiable.

Since his ascent to power in 2015, Magufuli has been praised by some Western donors for his bid to stamp out corruption and cut wasteful government spending.

Opponents, however, accuse him of becoming increasingly authoritarian by curbing political activity and cracking down on dissent.