Sunan Abi Dawud, Book 22, Hadith 3337 (USC-MSA)

Narrated Jabir ibn Abdullah: The Messenger of Allah would not say funeral prayer over a person who died while the debt was due from him. A dead Muslim was brought to him and he asked: Is there any debt due from him? They (the people) said: Yes, two dirhams. He said: Pray yourselves over your companion. Then AbuQatadah al-Ansari said: I shall pay them, Messenger of Allah. The Messenger of Allah then prayed over him. When Allah granted conquests to the Messenger of Allah, he said: I am nearer to every believer than himself, so if anyone (dies and) leaves a debt, I shall be responsible for paying it; and if anyone leaves property, it goes to his heirs.

حَدَّثَنَا مُحَمَّدُ بْنُ الْمُتَوَكِّلِ الْعَسْقَلاَنِيُّ، حَدَّثَنَا عَبْدُ الرَّزَّاقِ، أَخْبَرَنَا مَعْمَرٌ، عَنِ الزُّهْرِيِّ، عَنْ أَبِي سَلَمَةَ، عَنْ جَابِرٍ، قَالَ كَانَ رَسُولُ اللَّهِ صلى الله عليه وسلم لاَ يُصَلِّي عَلَى رَجُلٍ مَاتَ وَعَلَيْهِ دَيْنٌ فَأُتِيَ بِمَيِّتٍ فَقَالَ ‏"‏ أَعَلَيْهِ دَيْنٌ ‏"‏ ‏.‏ قَالُوا نَعَمْ دِينَارَانِ ‏.‏ قَالَ ‏"‏ صَلُّوا عَلَى صَاحِبِكُمْ ‏"‏ ‏.‏ فَقَالَ أَبُو قَتَادَةَ الأَنْصَارِيُّ هُمَا عَلَىَّ يَا رَسُولَ اللَّهِ ‏.‏ قَالَ فَصَلَّى عَلَيْهِ رَسُولُ اللَّهِ صلى الله عليه وسلم فَلَمَّا فَتَحَ اللَّهُ عَلَى رَسُولِ اللَّهِ صلى الله عليه وسلم قَالَ ‏"‏ أَنَا أَوْلَى بِكُلِّ مُؤْمِنٍ مِنْ نَفْسِهِ فَمَنْ تَرَكَ دَيْنًا فَعَلَىَّ قَضَاؤُهُ وَمَنْ تَرَكَ مَالاً فَلِوَرَثَتِهِ ‏"‏ ‏.‏

sunnah.com