Abdullah bin Umar reported,

When Abdullah bin Ubayy died, his son Abdullah bin Abdullah came to the Messenger of Allah ﷺ and asked him to give him his shirt to shroud his father in. He gave it to him. Then he asked him to pray over him, so the Messenger of Allah ﷺ stood up to pray over him.Umar got up and grabbed the garment of the Messenger of Allah ﷺ and said, "Messenger of Allah, are you going to pray over him when your Lord has forbidden you to pray over him?"The Messenger of Allah ﷺ replied, "Allah has only given me a choice. He said, 'Ask forgiveness for them or do not ask forgiveness for them. Even if you ask forgiveness for them seventy times' [Tawbah 9:80], and I will exceed seventy."Umar said, "He is a hypocrite."The Messenger of Allah ﷺ prayed over him, then Allah revealed, "And do not ever pray over any of them who has died, nor stand at his grave" [Tawbah 9:84].

Bukhari 4670

Sahih

حدثني عبيد بن إسماعيل عن أبي أسامة عن عبيد الله عن نافع

عن ابن عمر رضي الله عنهما قال

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

البخاري 4670صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Tafsir
Chapter
His saying, "Seek forgiveness for them or do not seek forgiveness for them. If you seek forgiveness for them seventy times"
Numbering
Darussalam 4670
Bukhari 4670