The Messenger of Allah ﷺ would not perform the funeral prayer over a man who died while owing a debt. A deceased man was once brought to him, and he asked, "Does he owe any debt?"They replied, "Yes, two dinars."He said, "Pray over your companion."Abu Qatada al-Ansari said, "They are upon me to pay, Messenger of Allah."So the Messenger of Allah ﷺ prayed over him. Later, when Allah granted victory to His Messenger ﷺ, he said, "I am closer to every believer than his own self. So whoever leaves behind a debt, its repayment is upon me, and whoever leaves behind wealth, it belongs to his heirs."
حدثنا محمد بن المتوكل العسقلاني حدثنا عبد الرزاق أخبرنا معمر عن الزهري عن أبي سلمة
كان رسول الله ﷺ لا يصلي على رجل مات وعليه دين فأتي بميت فقال أعليه دين قالوا نعم ديناران قال صلوا على صاحبكم فقال أبو قتادة الأنصاري هما علي يا رسول الله قال فصلى عليه رسول الله ﷺ فلما فتح الله على رسول الله ﷺ قال أنا أولى بكل مؤمن من نفسه فمن ترك دينا فعلي قضاؤه ومن ترك مالا فلورثته
Sourcing, [sahih] Nasai narrated it in the Book of Funerals, chapter on the prayer over one who has debt, hadith: 1964, from the hadith of Abdul-Razzaq, and it is found in his Musannaf, hadith: 15257. Ibn Hibban graded it sahih, hadith: 1162, and so did Ibn Jarud, hadith: 1111. The hadith has supporting narrations in Ahmad, 3/330, and Hakim, 2/57, 58, and others. See also hadith: 2954.