It was narrated from Abu Hurairah that:
if a believer died with debts outstanding, the Messenger of Allah would ask whether he had left behind anything to pay off his debts. If they said yes, he would pray for him, but if they said no, he would say: Pray for your companion. Then, when Allah made His Messenger rich through conquest, he said: I am closer to the believers than their own selves. Whoever dies and leaves behind a debt, I will pay it, and whoever leavers behind wealth, it is for his heirs.