Egypt’s prime minister has sacked the justice minister, Ahmed al-Zind, after he was criticised for saying he would jail Islam’s prophet Muhammad himself if he broke the law.

Zind’s comments came in a televised interview on Friday. Upon realising what he had said, Zind immediately stopped and said: “I ask for forgiveness from God.” He also issued an apology in another interview on Saturday, but to no avail.

“Prime minister Sherif Ismail issued a decree today to relieve Ahmed al-Zind ... of his position,” a government statement said, giving no more details.

Zind, a former appeals court judge, had been publicly outspoken in his criticism of the Muslim Brotherhood removed from power by the army in mid-2013 and banned as a terrorist group.

He has in the past denounced the 2011 revolt that ended Hosni Mubarak’s 30-year rule and ushered in the election that brought the Islamist movement to power. He has also been a strong defender of the judiciary and its powerful position.

Egyptian judges issued a statement opposing Zind’s removal over what the head of the Judges Club told Reuters was a slip of the tongue that could have happened to anyone.

“Egypt’s judges are sorry that someone who defended Egypt and its people, judiciary and nation in the face of the terrorist organisation that wanted to bring it down should be punished in this way,” said Abdallah Fathi.

Egyptian courts have been absolving Mubarak-era officials, while imposing long sentences on liberal and Islamist activists.

Egypt’s judiciary has faced criticism from rights groups in the past two years after judges issued mass death sentences against Muslim Brotherhood supporters, locking up youth activists and sentencing writers and journalists.

Zind’s predecessor was also forced to resign last May after saying the son of a garbage collector was ineligible to serve as a judge.

It was not immediately clear who would replace him.

Reuters and Agence France-Presse contributed to this report