Abu Hurairah reported,

Whenever a deceased man with an outstanding debt was brought to the Messenger of Allah ﷺ, he would ask, "Did he leave behind anything to settle it?"If they answered, "Yes, he left enough to cover it," he would perform the funeral prayer over him. Otherwise, he would say to the Muslims, "Pray over your companion."When Allah granted him the conquests, he stood and said, "I am closer to the believers than they are to themselves. Whoever among the believers dies leaving a debt, its payment is upon me, and whoever leaves wealth, it belongs to his heirs."

Ahmad 9848

Sahih

حدثنا حجاج قال حدثنا ليث قال حدثنا عقيل عن ابن شهاب عن أبي سلمة بن عبد الرحمن

عن أبي هريرة

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

أحمد 9848صحيح
Contents
Reference
Commentary
Ayat
Collection
Musnad Ahmad
Book
Abu Hurairah
Numbering
Darussalam 9848
Ahmad 9848