Sayyiduna Abu Hurayrah (may Allah be pleased with him) said: A man would be brought to him (peace and blessings be upon him) (that is, a deceased person) (the narrator said: I think, a man in debt), and he (peace and blessings be upon him) would ask: "Has he left anything with which his debt can be paid?" If he was told that he had left wealth, he (peace and blessings be upon him) would pray the funeral prayer over him; and if there was nothing, he (peace and blessings be upon him) would say to the Companions (may Allah be pleased with them): "Pray the funeral prayer over your companion." When many conquests came, he (peace and blessings be upon him) said: "I am closer to the believers than their own selves. Whoever dies in debt, I will pay it off, and whoever leaves wealth, it is for his heirs."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب النكاح / 13297