When ʿAbdullah bin Ubai bin Salul died, Messenger of Allah ﷺ was called upon to offer his funeral prayer. When Messenger of Allah ﷺ 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. Messenger of Allah ﷺ 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): Messenger of Allah ﷺ 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 Messenger of Allah ﷺ on that day. And Allah and His Apostle know better."
أَنَّهُ قَالَ لَمَّا مَاتَ عَبْدُ اللَّهِ بْنُ أُبَىٍّ ابْنُ سَلُولَ دُعِيَ لَهُ رَسُولُ اللَّهِ ﷺ لِيُصَلِّيَ عَلَيْهِ فَلَمَّا قَامَ رَسُولُ اللَّهِ ﷺ وَثَبْتُ إِلَيْهِ فَقُلْتُ يَا رَسُولَ اللَّهِ أَتُصَلِّي عَلَى ابْنِ أُبَىٍّ وَقَدْ قَالَ يَوْمَ كَذَا وَكَذَا كَذَا وَكَذَا أُعَدِّدُ عَلَيْهِ قَوْلَهُ فَتَبَسَّمَ رَسُولُ اللَّهِ ﷺ وَقَالَ أَخِّرْ عَنِّي يَا عُمَرُ فَلَمَّا أَكْثَرْتُ عَلَيْهِ قَالَ إِنِّي خُيِّرْتُ فَاخْتَرْتُ لَوْ أَعْلَمُ أَنِّي إِنْ زِدْتُ عَلَى السَّبْعِينَ فَغُفِرَ لَهُ لَزِدْتُ عَلَيْهَا قَالَ فَصَلَّى عَلَيْهِ رَسُولُ اللَّهِ ﷺ ثُمَّ انْصَرَفَ فَلَمْ يَمْكُثْ إِلاَّ يَسِيرًا حَتَّى نَزَلَتِ الآيَتَانِ مِنْ {بَرَاءَةٌ} {وَلاَ تُصَلِّ عَلَى أَحَدٍ مِنْهُمْ مَاتَ أَبَدًا} إِلَى {وَهُمْ فَاسِقُونَ} قَالَ فَعَجِبْتُ بَعْدُ مِنْ جُرْأَتِي عَلَى رَسُولِ اللَّهِ ﷺ يَوْمَئِذٍ وَاللَّهُ وَرَسُولُهُ أَعْلَمُ