(84) باب مَا يُكْرَهُ مِنَ الصَّلاَةِ عَلَى الْمُنَافِقِينَ وَالاِسْتِغْفَارِ لِلْمُشْرِكِينَ
Narrated `Umar bin Al-Khattab:
When `Abdullah bin Ubai bin Salul died, Allah's Messenger (ﷺ) (p.b.u.h) was called upon to offer his funeral prayer. When Allah's Messenger (ﷺ) stood up to offer the prayer, I got up quickly and said, "O Allah's Apostle! Are you going to pray for Ibn Ubai and he said so and so on such and such occasions?" And started mentioning all that he had said. Allah's Messenger (ﷺ) smiled and said, "O `Umar! Go away from me." When I talked too much he said, "I have been given the choice and so I have chosen (to offer the prayer). Had I known that he would be forgiven by asking for Allah's forgiveness for more than seventy times, surely I would have done so." (`Umar added): Allah's Messenger (ﷺ) offered his funeral prayer and returned and after a short while the two verses of Surat Bara' were revealed: i.e. "And never (O Muhammad) pray for any of them who dies . . . (to the end of the verse) rebellion (9.84)" -- (`Umar added), "Later I astonished at my daring before Allah's Messenger (ﷺ) on that day. And Allah and His Apostle know better."
Reference: Sahih al-Bukhari 1366
In-book reference: Book 23, Hadith 119
USC-MSA web (English) reference(deprecated numbering scheme): Vol. 2, Book 23, Hadith 447