"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.'"
أَنَّ رَسُولَ اللَّهِ ﷺ كَانَ يُؤْتَى بِالرَّجُلِ الْمُتَوَفَّى عَلَيْهِ الدَّيْنُ فَيَقُولُ هَلْ تَرَكَ لِدَيْنِهِ مِنْ قَضَاءٍ فَإِنْ حُدِّثَ أَنَّهُ تَرَكَ وَفَاءً صَلَّى عَلَيْهِ وَإِلاَّ قَالَ لِلْمُسْلِمِينَ صَلُّوا عَلَى صَاحِبِكُمْ فَلَمَّا فَتَحَ اللَّهُ عَلَيْهِ الْفُتُوحَ قَامَ فَقَالَ أَنَا أَوْلَى بِالْمُؤْمِنِينَ مِنْ أَنْفُسِهِمْ فَمَنْ تُوُفِّيَ مِنَ الْمُسْلِمِينَ فَتَرَكَ دَيْنًا عَلَىَّ قَضَاؤُهُ وَمَنْ تَرَكَ مَالاً فَهُوَ لِوَرَثَتِهِ