From the route of Ibn Mas^ud, may Allah accept his deeds, who said: The Messenger of Allah, sallallahu ^alayhi wa sallam, said:
<<The blood of a Muslim person who testifies no one is God except Allah and that I am the Messenger of Allah, is lawfully taken in only one of three instances: the adulterer/adulteress who had been in a valid marriage, death penalty for one for killing another, and leaving the jama^ah by leaving Islam.>>
Narrated by al-Bukhari and Muslim.