Sunan Ibn Majah 2415
It was narrated from Abu Hurairah that:
if a believer died at the time of the Messenger of Allah ﷺ and he had debts, the Messenger of Allah ﷺ would ask: “Did he leave anything with which to off his debt?” If they said yes, then he would offer the funeral prayer for him, but if they said no, then he would say: “Pray for your companion.” When Allah granted his Prophet ﷺ the conquests, he said: “I am nearer to the believers than their own selves. Whoever dies owing a debt, I will pay it off for him, and whoever leaves behind wealth, it will be for his heirs.”
حَدَّثَنَا أَحْمَدُ بْنُ عَمْرِو بْنِ السَّرْحِ الْمِصْرِيُّ، حَدَّثَنَا عَبْدُ اللَّهِ بْنُ وَهْبٍ، أَخْبَرَنِي يُونُسُ، عَنِ ابْنِ شِهَابٍ، عَنْ أَبِي سَلَمَةَ، عَنْ أَبِي هُرَيْرَةَ، أَنَّ رَسُولَ اللَّهِ ﷺ كَانَ يَقُولُ إِذَا تُوُفِّيَ الْمُؤْمِنُ فِي عَهْدِ رَسُولِ اللَّهِ ﷺ وَعَلَيْهِ الدَّيْنُ فَيَسْأَلُ " هَلْ تَرَكَ لِدَيْنِهِ مِنْ قَضَاءٍ " . فَإِنْ قَالُوا نَعَمْ . صَلَّى عَلَيْهِ وَإِنْ قَالُوا لاَ . قَالَ " صَلُّوا عَلَى صَاحِبِكُمْ " . فَلَمَّا فَتَحَ اللَّهُ عَلَى رَسُولِهِ الْفُتُوحَ قَالَ " أَنَا أَوْلَى بِالْمُؤْمِنِينَ مِنْ أَنْفُسِهِمْ فَمَنْ تُوُفِّيَ وَعَلَيْهِ دَيْنٌ فَعَلَىَّ قَضَاؤُهُ وَمَنْ تَرَكَ مَالاً فَهُوَ لِوَرَثَتِهِ " .