The Messenger of Allah ﷺ said, "The blood of a Muslim is not lawful to shed except for one of three offenses. A married person who commits adultery, who is to be stoned. A man who deliberately kills another, who is to be killed in return. Or a man who leaves Islam and wages war against Allah and His Messenger, who is to be killed, crucified, or banished from the land."
أخبرنا العباس بن محمد الدوري قال حدثنا أبو عامر العقدي عن إبراهيم بن طهمان عن عبد العزيز بن رفيع عن عبيد بن عمير
أن رسول الله ﷺ قال لا يحل دم امرئ مسلم إلا بإحدى ثلاث خصال زان محصن يرجم أو رجل قتل رجلا متعمدا فيقتل أو رجل يخرج من الإسلام يحارب الله عز وجل ورسوله فيقتل أو يصلب أو ينفى من الأرض
[Its chain of transmission is sahih] Abu Dawud reported it, Hudud, chapter on the ruling concerning one who apostatizes, no. 4353, from the hadith of Ibrahim bin Tahman, with this wording. It is also found in al-Kubra, no. 3511, and will come again, no. 4747.