Sahih Bukhari Volume 003, Book 037, Hadith Number 495.
Hadith Section/Book: Sahih Bukhari Sahih Bukhari Book 37. Transference of a Debt from one Person to Another (Al-Hawaala)
Narated By Abu Huraira : Whenever a dead man in debt was brought to Allah's Apostle he would ask, "Has he left anything to repay his debt?" If he was informed that he had left something to repay his debts, he would offer his funeral prayer, otherwise he would tell the Muslims to offer their friend's funeral prayer. When Allah made the Prophet wealthy through conquests, he said, "I am more rightful than other believers to be the guardian of the believers, so if a Muslim dies while in debt, I am responsible for the repayment of his debt, and whoever leaves wealth (after his death) it will belong to his heirs."