A man came to the Messenger of Allah ﷺ and said, "Messenger of Allah, tell me, if I am killed in the path of Allah while patient, seeking reward, advancing and not retreating, will Allah expiate my sins for me?"The Messenger of Allah ﷺ replied, "Yes."When the man turned away, the Messenger of Allah ﷺ called him back, or ordered that he be called back, and the man was summoned for him. The Messenger of Allah ﷺ asked, "What did you say?"The man repeated his question.The Messenger of Allah ﷺ said, "Yes, except for debt. Jibreel told me so."
أخبرنا محمد بن سلمة والحارث بن مسكين قراءة عليه وأنا أسمع عن ابن القاسم قال حدثني مالك عن يحيى بن سعيد عن سعيد بن أبي سعيد
جاء رجل إلى رسول الله ﷺ فقال يا رسول الله أرأيت إن قتلت في سبيل الله صابرا محتسبا مقبلا غير مدبر أيكفر الله عني خطاياي قال رسول الله ﷺ نعم فلما ولى الرجل ناداه رسول الله ﷺ أو أمر به فنودي له فقال رسول الله ﷺ كيف قلت فأعاد عليه قوله فقال رسول الله ﷺ نعم إلا الدين كذلك قال لي جبريل عليه السلام
Muslim narrated it in "The Book of Leadership," chapter "Whoever is killed in the path of Allah has his sins forgiven except for debt," Hadith 1885, from the hadith of Yahya bin Saeed Ansari through this same chain. It is also found in the Muwatta (Yahya's version), 2/461, and in Kubra, Hadith 4364.