Abdullah bin Umar reported,

When Abdullah bin Ubayy died, his son came to the Prophet ﷺ and said, "Messenger of Allah, give me your shirt so I may wrap him in it as a shroud, and pray over him, and ask forgiveness for him."The Prophet ﷺ gave him his shirt and said, "Let me know when it is time, and I will pray over him." So the son informed him.When he was about to pray over him, Umar رضي الله عنه pulled him back and said, "Has Allah not forbidden you to pray over the hypocrites?"The Prophet replied, "I am between two choices." Allah said, "Ask forgiveness for them or do not ask forgiveness for them. Even if you ask forgiveness for them seventy times, Allah will never forgive them" [Tawbah 9:80].So he prayed over him, and then this was revealed, "And never pray over any of them who has died" [Tawbah 9:84].

Azami 3620

Sahih

عن عبد الله بن عمر

أن عبد الله بن أبي لما توفي جاء ابنه إلى النبي ﷺ فقال: يا رسول الله! أعطني قميصك أكفنه فيه، وصل عليه، واستغفر له، فأعطاه النبي ﷺ قميصه فقال: آذني أصلي عليه فآذنه: فلما أراد أن يصلي عليه جذبه عمر رضي الله عنه فقال: أليس الله قد نهاك أن تصلي على المنافقين؟ فقال: أنا بين خيرتين قال: {استغفر لهم أو لا تستغفر لهم إن تستغفر لهم سبعين مرة فلن يغفر الله لهم} [سورة التوبة: ٨٠] فصلي عليه، فنزلت: {ولا تصل على أحد منهم مات أبدا} [سورة التوبة: ٨٤].

الأعظمي 3620صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Funerals
Chapter
Washing the deceased and shrouding him
Section
Shrouding Abdullah bin Abu Ubayy in the shirt of the Messenger of Allah ﷺ
Numbering
Jami al-Kamil 3620 (2nd edition)
Azami 3620