Many Tanzanians have condemned President John Magufuli’s comments that schoolgirls who give birth should not be allowed to return to school.
An online petition has been set up to get the president to reverse his comments.
Mr Magufuli warned schoolgirls at a rally on Monday that: "After getting pregnant, you are done."
A law passed in 2002 allows for expulsion of pregnant schoolgirls.
The law says the girls can be expelled and excluded from school for "offences against morality" and "wedlock".
Mr Magufuli, who was speaking at a public rally in Chalinze town, about 100km west of the main city Dar es Salaam, said that young mothers would be distracted if they were allowed back in school: "After calculating some few mathematics, she’d be asking the teacher in the classroom: ’Let me go out and breastfeed my crying baby.’"
He said that men who impregnate the schoolgirls should be imprisoned for 30 years and "put the energy they used to impregnate the girl into farming while in jail".
The president also criticised rights organisations who have been pushing the government to reverse the expulsion law:
"These NGOs should go out and open schools for parents. But they should not force the government [to take back the pupils].
"I’m giving out free education for students who have really decided to go and study, and now you want me to educate the parents?"
The BBC’s Sammy Awami in Tanzania reports that the crowd at the rally applauded the president’s comments.
At least 8,000 Tanzanian girls drop out of school every year due to pregnancy, according to a Human Rights Watch report.
The online petition says that the president’s support for the expulsion law would end the education of many girls and "propagate more discrimination".
It instead calls for the girls to be protected from early pregnancies while in school.
Tanzanians are also using the hashtag #ArudiShule (let her return) on Twitter to criticise the president’s comments and to highlight the plight of young women who get pregnant while in school.
Two weeks ago, Tanzania’s Vice-President Samia Suluhu called for young mothers to be readmitted school, saying they should not be denied a right to education.
Koitamet Olekina, executive director of the Maasai Education Discovery, a non-profit organisation that rescues girls from early marriages in Kenya, condemned Mr Magufuli’s comments:
"If Magufuli is standing on the pedestal of morality, then in my opinion, it would be more immoral to deny the Tanzanian girl child an opportunity to rise from a fall and be a better person than to relegate them to almost second-citizenship status for reasons sometimes out of their control."