Abu Qatada reported,

He heard him narrating from the Messenger of Allah ﷺ that he stood among them and reminded them that striving in the cause of Allah and faith in Allah are the best of deeds.A man stood up and asked, "Messenger of Allah, tell me, if I am killed in the cause of Allah, will Allah forgive my sins?"The Messenger of Allah ﷺ replied, "Yes, if you are killed in the cause of Allah while you are patient, seeking reward, advancing and not retreating, then yes, except for debt. Jibreel عليه السلام told me that."

Nasai 3159

Sahih

أخبرنا قتيبة قال حدثنا الليث عن سعيد بن أبي سعيد عن عبد الله بن أبي قتادة

عن أبي قتادة

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

النسائي 3159صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Nasai Sughra
Book
Jihad
Chapter
One who fought in the cause of Allah while owing a debt
Numbering
Darussalam 3159
Nasai 3159