We were sitting with the Prophet ﷺ when a funeral bier was brought.The people said, "Pray over him."He asked, "Did he owe any debt?"They said, "No."He asked, "Did he leave anything behind?"They said, "No."So he prayed over him.Then another bier was brought.They said, "Messenger of Allah, pray over him."He asked, "Did he owe any debt?"It was said, "Yes."He asked, "Did he leave anything behind?"They said, "Three dinars."So he prayed over him.Then a third was brought.They said, "Pray over him."He asked, "Did he leave anything behind?"They said, "No."He asked, "Did he owe any debt?"They said, "Three dinars."He said, "Pray over your companion yourselves."Abu Qatada said, "Pray over him, Messenger of Allah, and his debt is upon me."So he prayed over him.
كنا جلوسا عند النبي ﷺ إذ أتي بجنازة، فقالوا: صل عليها، فقال: هل عليه دين؟ قالوا: لا، قال: فهل ترك شيئا؟ قالوا: لا، فصلى عليه، ثم أتي بجنازة أخرى، فقالوا: يا رسول الله، صل عليها، قال: هل عليه دين؟ قيل: نعم، قال: فهل ترك شيئا؟ قالوا: ثلاثة دنانير، فصلى عليها، ثم أتي بالثالثة، فقالوا: صل عليها، قال: فهل ترك شيئا؟ قالوا: لا، قال: هل عليه دين؟ قالوا: ثلاثة دنانير، قال: صلوا على صاحبكم، قال أبو قتادة: صل عليه يا رسول الله وعلي دينه، فصلى عليه.
Bukhari narrated it in the Book of Suretyship (2289, 2295) through two routes from Makki bin Ibrahim and Abu Asim, both of them from Yazid bin Abu Ubayd, from Salama bin Akwa, and he mentioned it. The wording given is that of Makki, while the wording of Abu Asim is abridged.