(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. 'When I went on for too long, he said: Move away, O 'Umar, I was offered to choose one of two things and I have made my choice; it was said to me (Ask forgiveness for them (O Muhammad), or ask not forgiveness for them; though thou ask forgiveness for them seventy times Allah will not forgive them…) [9:80]. If I knew that Allah will forgive them if I were to add more than seventy one times, I will do so'. The Prophet, Allah bless him and give him peace, then walked with him and stood there until he prayed on the dead and finished with him. I was amazed that I dared to speak with the Messenger of Allah, Allah bless him and give him peace, in that way. And Allah and His Messenger know better'. 'Umar said: “Then, by Allah, only a short while later, Allah revealed (And never (O Muhammad) pray for one of them who dieth, nor stand by his grave…), after which the Messenger of Allah, Allah bless him and give him peace, never prayed on any hypocrite nor did he stand on the grave of any one of them until Allah, exalted is He, took him away to Him”.
The commentators of the Qur'an said: “The Messenger of Allah, Allah bless him and give him peace, was asked about what was done with 'Abd Allah ibn Ubayy and so he said: 'My gown will not avail him of anything with Allah. By Allah I did it because I was hoping that a thousand of his people would embrace Islam' ”.
Asbab Al-Nuzul by Al-Wahidi , trans. Mokrane Guezzou