كتاب الإيمان
1  
The Book of Faith
(47)
Chapter: Clarifying the emphatic prohibition against killing oneself; The one who kills himself with something will be punished with it in the fire; And that no one will enter Paradise but a muslim
(47)
باب غِلَظِ تَحْرِيمِ قَتْلِ الإِنْسَانِ نَفْسَهُ وَإِنَّ مَنْ قَتَلَ نَفْسَهُ بِشَيْءٍ عُذِّبَ بِهِ فِي النَّارِ وَأَنَّهُ لاَ يَدْخُلُ الْجَنَّةَ إِلاَّ نَفْسٌ مُسْلِمَةٌ
Sahih Muslim 111

It is narrated on the authority of Abu Huraira:

We participated in the Battle of Hunain along with the Messenger of Allah (ﷺ). He (the Holy Prophet) said about a man who claimed to be a Muslim that he was one of the denizens of the Fire (of Hell). When we were in the thick of the battle that man fought desperately and was wounded. It was said: Messenger of Allah, the person whom you at first called as the denizen of Fire fought desperately and died. Upon this the Messenger of Allah (ﷺ) remarked: He was doomed to the Fire (of Hell). Some men were on the verge of doubt (about his fate) when it was said that he was not dead but fatally wounded. When it was night he could not stand the (pain of his) wound and killed himself. The Apostle (ﷺ) was informed of that. He (the Holy Prophet) observed: Allah is Great, I bear testimony to the fact that I am the servant of Allah and His messenger. He then commanded Bilal to announce to the people that none but a Muslim would enter Paradise. Verily Allah helps this faith even by a sinful person.
وَحَدَّثَنَا مُحَمَّدُ بْنُ رَافِعٍ، وَعَبْدُ بْنُ حُمَيْدٍ، جَمِيعًا عَنْ عَبْدِ الرَّزَّاقِ، - قَالَ ابْنُ رَافِعٍ حَدَّثَنَا عَبْدُ الرَّزَّاقِ، - أَخْبَرَنَا مَعْمَرٌ، عَنِ الزُّهْرِيِّ، عَنِ ابْنِ الْمُسَيَّبِ، عَنْ أَبِي هُرَيْرَةَ، قَالَ شَهِدْنَا مَعَ رَسُولِ اللَّهِ صلى الله عليه وسلم حُنَيْنًا فَقَالَ لِرَجُلٍ مِمَّنْ يُدْعَى بِالإِسْلاَمِ ‏"‏ هَذَا مِنْ أَهْلِ النَّارِ ‏"‏ فَلَمَّا حَضَرْنَا الْقِتَالَ قَاتَلَ الرَّجُلُ قِتَالاً شَدِيدًا فَأَصَابَتْهُ جِرَاحَةٌ فَقِيلَ يَا رَسُولَ اللَّهِ الرَّجُلُ الَّذِي قُلْتَ لَهُ آنِفًا ‏"‏ إِنَّهُ مِنْ أَهْلِ النَّارِ ‏"‏ فَإِنَّهُ قَاتَلَ الْيَوْمَ قِتَالاً شَدِيدًا وَقَدْ مَاتَ ‏.‏ فَقَالَ النَّبِيُّ صلى الله عليه وسلم ‏"‏ إِلَى النَّارِ ‏"‏ فَكَادَ بَعْضُ الْمُسْلِمِينَ أَنْ يَرْتَابَ فَبَيْنَمَا هُمْ عَلَى ذَلِكَ إِذْ قِيلَ إِنَّهُ لَمْ يَمُتْ وَلَكِنَّ بِهِ جِرَاحًا شَدِيدًا فَلَمَّا كَانَ مِنَ اللَّيْلِ لَمْ يَصْبِرْ عَلَى الْجِرَاحِ فَقَتَلَ نَفْسَهُ فَأُخْبِرَ النَّبِيُّ صلى الله عليه وسلم بِذَلِكَ فَقَالَ ‏"‏ اللَّهُ أَكْبَرُ أَشْهَدُ أَنِّي عَبْدُ اللَّهِ وَرَسُولُهُ ‏"‏ ‏.‏ ثُمَّ أَمَرَ بِلاَلاً فَنَادَى فِي النَّاسِ ‏"‏ إِنَّهُ لاَ يَدْخُلُ الْجَنَّةَ إِلاَّ نَفْسٌ مُسْلِمَةٌ وَإِنَّ اللَّهَ يُؤَيِّدُ هَذَا الدِّينَ بِالرَّجُلِ الْفَاجِرِ ‏"‏ ‏.‏
Reference : Sahih Muslim 111
In-book reference : Book 1, Hadith 212
USC-MSA web (English) reference : Book 1, Hadith 205
  (deprecated numbering scheme)