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 shroud him in it."The Messenger of Allah ﷺ said, "Inform me when he is ready."When the Prophet ﷺ intended to pray over him, Umar bin Khattab said to him, "Is that something you should do?"The Prophet ﷺ prayed over him anyway and said, "I have been given a choice between two options, 'Whether you seek forgiveness for them or do not seek forgiveness for them' [Tawbah 9:80]."Then Allah عز وجل revealed, "And never pray over any of them who dies, nor stand at his grave" [Tawbah 9:84].

Ibn Majah 1523

Sahih

حدثنا أبو بشر بكر بن خلف حدثنا يحيى بن سعيد عن عبيد الله عن نافع

عن ابن عمر قال

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

ابن ماجه 1523صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Funerals
Chapter
Prayer for the people of the qibla
Numbering
Darussalam 1523
Ibn Majah 1523