The Messenger of Allah ﷺ said, "The blood of a Muslim who testifies that there is no god but Allah and that Muhammad is the Messenger of Allah is not lawful to shed except in one of three cases. A man who commits adultery after marriage, in which case he is stoned. A man who goes out to wage war against Allah and His Messenger, in which case he is killed, crucified, or banished from the land. Or a man who kills another person, in which case he is killed in retaliation."
حدثنا محمد بن سنان الباهلي حدثنا إبراهيم بن طهمان عن عبد العزيز بن رفيع عن عبيد بن عمير
قال رسول الله ﷺ لا يحل دم امرئ مسلم يشهد أن لا إله إلا الله وأن محمدا رسول الله إلا بإحدى ثلاث رجل زنى بعد إحصان فإنه يرجم ورجل خرج محاربا لله ورسوله فإنه يقتل أو يصلب أو ينفى من الأرض أو يقتل نفسا فيقتل بها
[Its chain of transmission is sahih] Nasai narrated it in Tahrim al-Dam, chapter on Crucifixion, no. 4053, from the hadith of Ibrahim bin Tahman, through this route.