Abdullah bin Abbas reported,

His son died at Qudayd, or perhaps at Usfan, and he said, "Kurayb, see how many people have gathered for him."Kurayb said, I went out and found that people had gathered for him, so I informed him.He asked, "Would you say they are forty?"I replied, "Forty."He said, "Yes. Bring him out, for I heard the Messenger of Allah ﷺ say, 'There is no Muslim man who dies and forty men, who associate nothing with Allah, stand in prayer over his funeral, except that Allah accepts their intercession for him.'"

Azami 934

Sahih

عن ابن عباس

أنه مات له ابن بقديد أو بعسفان، فقال: يا كريب، انظر ما اجتمع له من الناس قال: فخرجت فإذا ناس قد اجتمعوا له، فأخبرته، فقال: تقول: هم أربعون؟ قال: أربعون؟ قال: نعم. قال: أخرجوه، فإني سمعت رسول الله ﷺ يقول: ما من رجل مسلم يموت فيقوم على جنازته أربعون رجلا، لا يشركون بالله شيئا إلا شفعهم الله فيه.

الأعظمي 934صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Faith
Chapter
Faith in the intercession of the Prophet ﷺ and others
Section
Intercession of those who pray for the deceased
Numbering
Jami al-Kamil 934 (2nd edition)
Azami 934