(47) باب غِلَظِ تَحْرِيمِ قَتْلِ الإِنْسَانِ نَفْسَهُ وَإِنَّ مَنْ قَتَلَ نَفْسَهُ بِشَيْءٍ عُذِّبَ بِهِ فِي النَّارِ وَأَنَّهُ لاَ يَدْخُلُ الْجَنَّةَ إِلاَّ نَفْسٌ مُسْلِمَةٌ
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(deprecated numbering scheme): Book 1, Hadith 205