Jami` at-Tirmidhi 1070
Abu Hurairah narrated:
"A deceased man would be brought to the Messenger of Allah while a debt was due upon him. So he would say: 'Has he left anything to pay off his debt?' If he was told that he had left something to pay it then he would pray (the funeral prayer) for him. Otherwise he would tell the Muslims: 'Pray for your companion.' So when Allah granted him the victories, he stood and said: 'I am more worthy in the case of the believers than they themselves are. So whoever among the believers dies and leaves a debt behind, then it is up to me to fulfill it. And whoever leaves wealth behind, then it is for his heirs.'"
حَدَّثَنَا أَبُو الْفَضْلِ، مَكْتُومُ بْنُ الْعَبَّاسِ التِّرْمِذِيُّ حَدَّثَنَا عَبْدُ اللَّهِ بْنُ صَالِحٍ، قَالَ حَدَّثَنِي اللَّيْثُ، قَالَ حَدَّثَنِي عُقَيْلٌ، عَنِ ابْنِ شِهَابٍ، قَالَ أَخْبَرَنِي أَبُو سَلَمَةَ بْنُ عَبْدِ الرَّحْمَنِ، عَنْ أَبِي هُرَيْرَةَ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم كَانَ يُؤْتَى بِالرَّجُلِ الْمُتَوَفَّى عَلَيْهِ الدَّيْنُ فَيَقُولُ ‏"‏ هَلْ تَرَكَ لِدَيْنِهِ مِنْ قَضَاءٍ ‏"‏ ‏.‏ فَإِنْ حُدِّثَ أَنَّهُ تَرَكَ وَفَاءً صَلَّى عَلَيْهِ وَإِلاَّ قَالَ لِلْمُسْلِمِينَ ‏"‏ صَلُّوا عَلَى صَاحِبِكُمْ ‏"‏ ‏.‏ فَلَمَّا فَتَحَ اللَّهُ عَلَيْهِ الْفُتُوحَ قَامَ فَقَالَ ‏"‏ أَنَا أَوْلَى بِالْمُؤْمِنِينَ مِنْ أَنْفُسِهِمْ فَمَنْ تُوُفِّيَ مِنَ الْمُسْلِمِينَ فَتَرَكَ دَيْنًا عَلَىَّ قَضَاؤُهُ وَمَنْ تَرَكَ مَالاً فَهُوَ لِوَرَثَتِهِ ‏"‏ ‏.‏ قَالَ أَبُو عِيسَى هَذَا حَدِيثٌ حَسَنٌ صَحِيحٌ ‏.‏ وَقَدْ رَوَاهُ يَحْيَى بْنُ بُكَيْرٍ وَغَيْرُ وَاحِدٍ عَنِ اللَّيْثِ بْنِ سَعْدٍ نَحْوَ حَدِيثِ عَبْدِ اللَّهِ بْنِ صَالِحٍ ‏.‏