A 19-year-old rule that banned pregnant students from attending school in Tanzania is to be scrapped, a minister says.

Education Minister Prof Joyce Ndalichako said on Wednesday that primary and secondary school students who drop out of school due to various reasons, including pregnancy, will now be allowed to return to the formal school system.

The government had set up a parallel education system for pregnant schoolgirls with officials saying this would protect other students from “bad influence”.

The late Tanzania President John Pombe Magufuli reinforced the law initially passed in 2002 which allowed for the expulsion of pregnant schoolgirls.

The law said the girls could be expelled and excluded from school for “offences against morality” and “wedlock”.

Women’s rights groups had long urged the government to change the law.

Magufuli warned that “after getting pregnant, you are done”.

He also announced that men who impregnate schoolgirls should be imprisoned for 30 years.

Prof Ndalichako said she would give more information about the way forward.