Abdullah bin Umar reported,

When Abdullah bin Ubayy died, his son came to the Messenger of Allah ﷺ and said, "Messenger of Allah, give me your shirt so that I may shroud him in it, and pray over him, and seek forgiveness for him."So he gave him his shirt and said, "Inform me when he is ready."When he was about to pray over him, Umar said, "Has Allah not forbidden you to pray over the hypocrites?"He replied, "I have been given a choice between two options, 'Ask forgiveness for them or do not ask forgiveness for them' [Tawbah 9:80]." Then he prayed over him.So Allah, the Exalted, revealed, "And never pray over any of them who has died" [Tawbah 9:84].He said, "So the prayer over them was abandoned."

Ahmad 4680

Sahih

حدثنا يحيى عن عبيد الله حدثني نافع

عن ابن عمر قال

لما مات عبد الله بن أبي جاء ابنه إلى رسول الله ﷺ فقال يا رسول الله أعطني قميصك حتى أكفنه فيه وصل عليه واستغفر له فأعطاه قميصه وقال آذني به فلما ذهب ليصلي عليه قال يعني عمر قد نهاك الله أن تصلي على المنافقين فقال أنا بين خيرتين {استغفر لهم أو لا تستغفر لهم} فصلى عليه فأنزل الله تعالى {ولا تصل على أحد منهم مات أبدا} قال فتركت الصلاة عليهم

أحمد 4680صحيح
Contents
Reference
Commentary
Ayat
Collection
Musnad Ahmad
Book
Abdullah bin Umar
Numbering
Darussalam 4680
Ahmad 4680