Abdullah bin Umar reported,

When Abdullah bin Ubayy died, his son Abdullah bin Abdullah came to the Messenger of Allah ﷺ, who gave him his shirt and instructed him to shroud his father in it. Then he stood to pray over him, but Umar bin Khattab took hold of his garment and said, "Are you praying over him when he is a hypocrite, and Allah has forbidden you to seek forgiveness for them?"He replied, "Allah has only given me a choice," or he said, "Allah has only informed me," for He 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]. He said, "I will exceed seventy."So the Messenger of Allah ﷺ prayed over him, and we prayed with him. Then Allah revealed to him, "And never pray over any of them who has died, nor stand at his grave. Indeed, they disbelieved in Allah and His Messenger and died while they were defiantly disobedient" [Tawbah 9:84].

Bukhari 4672

Sahih

حدثني إبراهيم بن المنذر حدثنا أنس بن عياض عن عبيد الله عن نافع

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

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

البخاري 4672صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Tafsir
Chapter
His saying, "And do not pray over any of them who dies, ever, nor stand at his grave"
Numbering
Darussalam 4672
Bukhari 4672