Sahih al-Bukhari 2298
Narrated Abu Huraira:
Whenever a dead man in debt was brought to Allah's Apostle he would ask, "Has he left anything to repay his debt?" If he was informed that he had left something to repay his debts, he would offer his funeral prayer, otherwise he would tell the Muslims to offer their friend's funeral prayer. When Allah made the Prophet wealthy through conquests, he said, "I am more rightful than other believers to be the guardian of the believers, so if a Muslim dies while in debt, I am responsible for the repayment of his debt, and whoever leaves wealth (after his death) it will belong to his heirs. "
حَدَّثَنَا يَحْيَى بْنُ بُكَيْرٍ، حَدَّثَنَا اللَّيْثُ، عَنْ عُقَيْلٍ، عَنِ ابْنِ شِهَابٍ، عَنْ أَبِي سَلَمَةَ، عَنْ أَبِي هُرَيْرَةَ ـ رضى الله عنه ـ أَنَّ رَسُولَ اللَّهِ ﷺ كَانَ يُؤْتَى بِالرَّجُلِ الْمُتَوَفَّى عَلَيْهِ الدَّيْنُ فَيَسْأَلُ " هَلْ تَرَكَ لِدَيْنِهِ فَضْلاً ". فَإِنْ حُدِّثَ أَنَّهُ تَرَكَ لِدَيْنِهِ وَفَاءً صَلَّى، وَإِلاَّ قَالَ لِلْمُسْلِمِينَ " صَلُّوا عَلَى صَاحِبِكُمْ ". فَلَمَّا فَتَحَ اللَّهُ عَلَيْهِ الْفُتُوحَ قَالَ " أَنَا أَوْلَى بِالْمُؤْمِنِينَ مِنْ أَنْفُسِهِمْ، فَمَنْ تُوُفِّيَ مِنَ الْمُؤْمِنِينَ فَتَرَكَ دَيْنًا فَعَلَىَّ قَضَاؤُهُ، وَمَنْ تَرَكَ مَالاً فَلِوَرَثَتِهِ ".