Sunan an-Nasa'i, Volume 3, Book 21, Hadith 1964 (DarusSalam)

It was narrated that Jabir said: "The Prophet would not pray for a man who owed a debt. A deceased person was brought to him and he said: 'Does he owe any debt?' They said: 'Yes, he owes two Dinars.' He said: 'Pray for your companion.' Abu Qatadah said: 'I will pay them, O Messenger of Alllah, So he prayed for him. Then, when Allah made His Messenger rich though conquest, he said: ' I am closer to each believer than his own self. Whoever leaves behind a debt, I will pay it, and whoever leaves behind wealth, it is for his heirs."

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

sunnah.com