Abu Hurairah reported,

Whenever a deceased man with a debt was brought to the Messenger of Allah ﷺ, he would ask whether the man had left behind enough to settle his debt. If he was told that the man had left enough to cover it, he would pray over him. Otherwise, he would say, "Pray over your companion."When Allah granted him victories and conquests, he said, "I am closer to the believers than they are to themselves. Whoever dies leaving a debt, its repayment is upon me, and whoever leaves wealth, it belongs to his heirs."

Muslim 4157

Sahih

و حدثني زهير بن حرب حدثنا أبو صفوان الأموي عن يونس الأيلي ح و حدثني حرملة بن يحيى واللفظ له قال أخبرنا عبد الله بن وهب أخبرني يونس عن ابن شهاب عن أبي سلمة بن عبد الرحمن

عن أبي هريرة

أن رسول الله ﷺ كان يؤتى بالرجل الميت عليه الدين فيسأل هل ترك لدينه من قضاء فإن حدث أنه ترك وفاء صلى عليه وإلا قال صلوا على صاحبكم فلما فتح الله عليه الفتوح قال أنا أولى بالمؤمنين من أنفسهم فمن توفي وعليه دين فعلي قضاؤه ومن ترك مالا فهو لورثته

مسلم 4157صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Obligatory duties
Chapter
Whoever leaves wealth, it is for his heirs
Numbering
Darussalam 4157
Muslim 4157