When Abdullah bin Ubayy bin Salul died, the Messenger of Allah ﷺ was called to perform the funeral prayer over him. When the Messenger of Allah ﷺ stood up to do so, I leapt toward him and said, "Messenger of Allah, are you going to pray over Ibn Ubayy when he said such-and-such on such-and-such a day?" I began enumerating his offenses.The Messenger of Allah ﷺ smiled and said, "Step back from me, Umar."When I persisted, he said, "I have been given a choice, and I have made my choice. If I knew that by asking forgiveness for him more than seventy times he would be forgiven, I would do so."Then the Messenger of Allah ﷺ prayed over him and departed. Only a short time passed before the two verses of Surah Bara'ah were revealed, "And never pray over any of them who has died, nor stand at his grave. They disbelieved in Allah and His Messenger and died as defiantly disobedient" [Tawbah 9:84].Afterward I was astonished at my boldness toward the Messenger of Allah ﷺ that day. Allah and His Messenger know best.
أخبرنا محمد بن عبد الله بن المبارك قال حدثنا حجين بن المثنى قال حدثنا الليث عن عقيل عن ابن شهاب عن عبيد الله بن عبد الله عن عبد الله بن عباس
لما مات عبد الله بن أبي ابن سلول دعي له رسول الله ﷺ ليصلي عليه فلما قام رسول الله ﷺ وثبت إليه فقلت يا رسول الله تصلي على ابن أبي وقد قال يوم كذا وكذا كذا وكذا أعدد عليه فتبسم رسول الله ﷺ وقال أخر عني يا عمر فلما أكثرت عليه قال إني قد خيرت فاخترت فلو علمت أني لو زدت على السبعين غفر له لزدت عليها فصلى عليه رسول الله ﷺ ثم انصرف فلم يمكث إلا يسيرا حتى نزلت الآيتان من براءة {ولا تصل على أحد منهم مات أبدا ولا تقم على قبره إنهم كفروا بالله ورسوله وماتوا وهم فاسقون} فعجبت بعد من جرأتي على رسول الله ﷺ يومئذ والله ورسوله أعلم
Reported by Bukhari, in the Book of Funerals, chapter on what is disliked regarding praying over hypocrites and seeking forgiveness for polytheists, hadith no. 1366, from the hadith of Layth bin Saad through the same chain, and it is also found in Kubra, hadith no. 2093.