Abu Hurairah reported,

We were with the Messenger of Allah ﷺ when he said about a man who claimed to be a Muslim, "This man is among the people of the Fire."When the battle began, the man fought fiercely until he was wounded. Someone said, "Messenger of Allah, the man you said was among the people of the Fire fought fiercely today and has now died."The Prophet ﷺ said, "He is in the Fire."Some people were almost overcome with doubt. While they were in that state, word came that the man had not died but was severely wounded. When night fell, he could not bear the pain of his wounds and killed himself. The Prophet ﷺ was informed of this and said, "Allah is the Greatest. I bear witness that I am the servant of Allah and His Messenger."Then he ordered Bilal to announce to the people, "None shall enter Paradise except a Muslim soul, and indeed Allah supports this religion even through a wicked man."

Bukhari 3062

Sahih

حدثنا أبو اليمان أخبرنا شعيب عن الزهري ح و حدثني محمود بن غيلان حدثنا عبد الرزاق أخبرنا معمر عن الزهري عن ابن المسيب

عن أبي هريرة رضي الله عنه قال

شهدنا مع رسول الله ﷺ فقال لرجل ممن يدعي الإسلام هذا من أهل النار فلما حضر القتال قاتل الرجل قتالا شديدا فأصابته جراحة فقيل يا رسول الله الذي قلت له إنه من أهل النار فإنه قد قاتل اليوم قتالا شديدا وقد مات فقال النبي ﷺ إلى النار قال فكاد بعض الناس أن يرتاب فبينما هم على ذلك إذ قيل إنه لم يمت ولكن به جراحا شديدا فلما كان من الليل لم يصبر على الجراح فقتل نفسه فأخبر النبي ﷺ بذلك فقال الله أكبر أشهد أني عبد الله ورسوله ثم أمر بلالا فنادى بالناس إنه لا يدخل الجنة إلا نفس مسلمة وإن الله ليؤيد هذا الدين بالرجل الفاجر

البخاري 3062صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Jihad and expeditions
Chapter
Allah supports the religion through the wicked man
Numbering
Darussalam 3062
Bukhari 3062