(And never (O Muhammad) pray for one of them who dieth, nor stand by his grave...) [9:84]. Isma'il ibn 'Abd al-Rahman ibn Ahmad al-Wa'iz informed us through dictation> 'Abd Allah ibn Muhammad ibn Nasr> Yusuf ibn 'Asim al-Razi> al-'Abbas ibn al-Walid al-Narsi> Yahya ibn Sa'id al-Qattan> 'Ubayd Allah ibn 'Umar> Nafi'> Ibn 'Umar who said: “When 'Abd Allah ibn Ubayy died, his son went to the Messenger of Allah, Allah bless him and give him peace, and said: 'Give me your gown to use as a shroud for my father, perform the prayer of the dead on him and seek forgiveness for him'. The Prophet gave him his gown and then said: 'Inform me [when you are ready to bury him] so that I may perform the prayer of the dead on him'. When he was informed and He was about to perform the prayer, 'Umar ibn al-Khattab pulled him and said: 'Did Allah not forbid praying on the hypocrites?' The Prophet said: 'I have been given the choice to seek forgiveness for them or not to seek it', and so he performed the prayer of the dead on him. Then this verse was revealed (And never (O Muhammad) pray for one of them who dieth, nor stand by his grave) upon which he stopped praying on them”. This was narrated by Bukhari from Musaddid and by Muslim from Abu Qudamah 'Ubayd Allah ibn Sa'id, and both Musaddid and 'Ubayd Allah ibn Sa'id related it from Yahya ibn Sa'id. Isma'il ibn Ibrahim al-Nasrabadhi informed us> Abu Bakr ibn Malik al-Qati'i> 'Abd Allah ibn Ahmad ibn Hanbal> Ahmad ibn Hanbal> Ya'qub>> ibn Ibrahim ibn Sa'd> his father> Muhammad ibn Ishaq> al-Zuhri> 'Ubayd Allah ibn 'Abd Allah ibn 'Utbah ibn Mas'ud> Ibn 'Abbas who said: “I heard 'Umar ibn al-Khattab saying: 'When 'Abd Allah ibn Ubayy died, the Messenger of Allah, Allah bless him and give him peace, was called to pray on him. When he stood up in front of the body to perform the prayer, I moved around until I stood close to his chest and said: 'O Messenger of Allah, will you pray on the enemy of Allah 'Abd Allah ibn Ubayy who said such-and-such on such a day and such-and-such on such a day', and he counted all the things he had said, all while the Messenger of Allah, Allah bless him and give him peace, kept smiling.
Asbab Al-Nuzul by Al-Wahidi , trans. Mokrane Guezzou