Mishkat al-Masabih 3446
‘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.)
عَنْ عَبْدِ اللَّهِ بْنِ مَسْعُودٍ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: 
" لَا يَحِلُّ دَمُ امْرِئٍ مُسْلِمٍ يَشْهَدُ أَنْ لَا إِلَهَ إِلَّا اللَّهُ وَأَنِّي رَسُولُ اللَّهِ إِلَّا بِإِحْدَى ثَلَاثٍ: النَّفْسُ بِالنَّفْسِ وَالثَّيِّبُ الزَّانِي وَالْمَارِقُ لدينِهِ التَّارِكُ للجماعةِ "