The Messenger of Allah ﷺ said, "It is not lawful to shed the blood of a Muslim who testifies that there is no god but Allah and that I am the Messenger of Allah, except in one of three cases: a life for a life, a married person who commits adultery, and one who abandons his religion and separates from the community."
حدثنا علي بن محمد وأبو بكر بن خلاد الباهلي قالا حدثنا وكيع عن الأعمش عن عبد الله بن مرة عن مسروق عن عبد الله وهو
قال رسول الله ﷺ لا يحل دم امرئ مسلم يشهد أن لا إله إلا الله وأني رسول الله إلا أحد ثلاثة نفر النفس بالنفس والثيب الزاني والتارك لدينه المفارق للجماعة
Bukhari transmitted it in the chapters on blood money, in the chapter "The saying of Allah Most High, 'A life for a life, and an eye for an eye,'" hadith no. 6878, from the hadith of Amash, through this same chain. And Muslim transmitted it in the chapters on retaliatory killing and those who wage war, in the chapter on what makes a Muslim's blood lawful to shed, hadith no. 1676, from the hadith of Waki, through this same chain.