The death penalty for apostasy is part of Islamic law. It’s based on the Qur’an: “They wish you would disbelieve as they disbelieved so you would be alike. So do not take from among them allies until they emigrate for the cause of Allah. But if they turn away, then seize them and kill them wherever you find them and take not from among them any ally or helper.” (Qur’an 4:89)
A hadith depicts Muhammad saying: “Whoever changed his Islamic religion, then kill him” (Bukhari 9.84.57). The death penalty for apostasy is part of Islamic law according to all the schools of Islamic jurisprudence.