On the authority of Abdullah ibn Mas’ud reported, peace and blessings of Allah be upon him narrated that: The Messenger of Allah, peace and blessings be upon him, said:
It is unlawful to shed the blood of a Muslim person who testifies that there is no God but Allah and that I am the Messenger of Allah except in one of three cases: the married person who commits adultery, legal retaliation for murder, and a person who abandons their religion and opposes the community.
لَا يَحِلُّ دَمُ امْرِئٍ مُسْلِمٍ يَشْهَدُ أَنْ لَا إِلَهَ إِلَّا اللَّهُ وَأَنِّي رَسُولُ اللَّهِ إِلَّا بِإِحْدَى ثَلَاثٍ الثَّيِّبُ الزَّانِي وَالنَّفْسُ بِالنَّفْسِ وَالتَّارِكُ لِدِينِهِ الْمُفَارِقُ لِلْجَمَاعَةِ
Source: Sahih Bukhari 6484
Authenticity: Muttafaqun Alayhi