It is narrated from Sayyiduna Ali bin Abi Talib (may Allah be pleased with him) that whenever a funeral was brought to the Messenger of Allah (peace and blessings be upon him), he (peace and blessings be upon him) would ask only this about him: "He was not in debt, was he?" If it was said: Yes, he (peace and blessings be upon him) would refrain from leading the funeral prayer, and if it was said: No, he (peace and blessings be upon him) would lead the funeral prayer. Then a funeral was brought. He (peace and blessings be upon him) stood up and asked his companions: "Was this brother of yours in any debt?" They said: He owes two dinars of debt. The Messenger of Allah (peace and blessings be upon him) stepped back and said: "Offer the funeral prayer over him yourselves." Sayyiduna Ali (may Allah be pleased with him) said: O Messenger of Allah (peace and blessings be upon him), both of them are upon me, and the deceased is free of them. He (peace and blessings be upon him) stepped forward, led the funeral prayer and said: "O Ali, may Allah reward you well. May Allah Almighty lighten your burden just as you have lightened your brother's burden of debt. Whoever dies while in debt is held in pledge for that debt. So whoever pays off the debt of a deceased person, Allah Almighty will lift his burden on the Day of Resurrection." Some of the Companions (may Allah be pleased with them) said: Is this particular to Ali (may Allah be pleased with him), or general for the Muslims? He (peace and blessings be upon him) said: "No, rather it is general for all the Muslims."
Ata' bin Ajlan is da'if (weak), and the narrations about Abu Qatadah taking on the debt of the deceased are more authentic.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الحوالة / 11399