‘Abdallah b. Mas'ud reported God’s Messenger as saying, “The blood of a Muslim who testifies that there is no god but God and that I am God’s Messenger may not lawfully be shed but for one of three reasons:
a life for a life; a married man who commits fornication; and one who turns aside from his religion and abandons the community.”
(Bukhari and Muslim.)