Messenger of Allah ﷺ stood up and said: By Him besides Whom there is no god but He, the blood of a Muslim who bears the testimony that there is no god but Allah, and I am His Messenger, may be lawfully shed only in case of three persons: the one who abandons Islam, and deserts the community [Ahmad, one of the narrators, is doubtful whether the Prophet ﷺ used the word li'l-jama'ah or al-jama'ah), and the married adulterer, and life for life. (Using translation from Muslim 1676c)
قَامَ فِينَا رَسُولُ اللهِ ﷺ فَقَالَ وَالَّذِي لَا إِلَهَ غَيْرُهُ لَا يَحِلُّ دَمُ رَجُلٍ مُسْلِمٍ يَشْهَدُ أَنْ لَا إِلَهَ إِلَّا اللهُ وَأَنِّي رَسُولُ اللهِ إِلَّا ثَلَاثَةُ نَفَرٍ التَّارِكُ الْإِسْلَامَ الْمُفَارِقُ لِلْجَمَاعَةِ أَوِ الْجَمَاعَةَ وَالثَّيِّبُ الزَّانِي وَالنَّفْسُ بِالنَّفْسِ قَالَ الْأَعْمَشُ فَحَدَّثْتُ بِهِ إِبْرَاهِيمَ فَحَدَّثَنِي عَنِ الْأَسْوَدِ عَنْ عَائِشَةَ بِمِثْلِهِ