Abdullah bin Umar reported,

When Abdullah bin Ubayy bin Salul died, his son Abdullah bin Abdullah bin Ubayy came to the Messenger of Allah ﷺ and asked him for his shirt so that he might shroud his father in it, and he gave it to him. Then he asked him to pray over him, and the Messenger of Allah ﷺ rose to pray over him. Umar stood up, took hold of the Messenger of Allah's garment, 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 shall add more than seventy."Umar said, "But he is a hypocrite."The Messenger of Allah ﷺ prayed over him anyway, and Allah revealed, "And never pray over any of them who dies, nor stand at his grave" [Tawbah 9:84].

Azami 3740

Sahih

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

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

الأعظمي 3740صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Funerals
Chapter
Prayer over the deceased
Section
Prohibition of praying over hypocrites and polytheists and seeking forgiveness for them
Numbering
Jami al-Kamil 3740 (2nd edition)