The Messenger of Allah ﷺ would not say funeral prayer over a person who died while the debt was due from him. A dead Muslim was brought to him and he asked: Is there any debt due from him? They (the people) said: Yes, two dirhams. He said: Pray yourselves over your companion. Then AbuQatadah al-Ansari said: I shall pay them, Messenger of Allah. The Messenger of Allah ﷺ then prayed over him. When Allah granted conquests to the Messenger of Allah ﷺ, he said: I am nearer to every believer than himself, so if anyone (dies and) leaves a debt, I shall be responsible for paying it; and if anyone leaves property, it goes to his heirs. (Using translation from Abū Dāʾūd 3343)
كَانَ رَسُولُ اللهِ ﷺ لَا يُصَلِّي عَلَى أَحَدٍ عَلَيْهِ دَيْنٌ فَأُتِيَ بِمَيِّتٍ فَقَالَ هَلْ عَلَيْهِ دَيْنٌ؟ قَالُوا نَعَمْ يَا رَسُولَ اللهِ دِينَارَانِ قَالَ صَلُّوا عَلَى صَاحِبِكُمْ قَالَ أَبُو قَتَادَةَ هُمَا عَلَيَّ يَا رَسُولَ اللهِ فَصَلَّى عَلَيْهِ فَلَمَّا فَتَحَ اللهُ عَلَى رَسُولِهِ ﷺ قَالَ أَنَا أَوْلَى بِكُلِّ مُؤْمِنٍ مِنْ نَفْسِهِ فَمَنْ تَرَكَ دَيْنًا فَعَلَيَّ وَمَنْ تَرَكَ مَالًا فَلِوَرَثَتِهِ