When ʿAbdullah bin Ubai died, his son ʿAbdullah bin ʿAbdullah came to Messenger of Allah ﷺ who gave his shirt to him and ordered him to shroud his father in it. Then he stood up to offer the funeral prayer for the deceased, but ʿUmar bin Al-Khattab took hold of his garment and said, "Do you offer the funeral prayer for him though he was a hypocrite and Allah has forbidden you to ask forgiveness for hypocrites?" The Prophet ﷺ said, "Allah has given me the choice (or Allah has informed me) saying: "Whether you, O Muhammad, ask forgiveness for them, or do not ask forgiveness for them, even if you ask forgiveness for them seventy times, Allah will not forgive them," (9.80) The he added, "I will (appeal to Allah for his sake) more than seventy times." So Messenger of Allah ﷺ offered the funeral prayer for him and we too, offered the prayer along with him. Then Allah revealed: "And never, O Muhammad, pray (funeral prayer) for anyone of them that dies, nor stand at his grave. Certainly they disbelieved in Allah and His Apostle and died in a state of rebellion." (9.84)
لَمَّا تُوُفِّيَ عَبْدُ اللَّهِ بْنُ أُبَىٍّ جَاءَ ابْنُهُ عَبْدُ اللَّهِ بْنُ عَبْدِ اللَّهِ إِلَى رَسُولِ اللَّهِ ﷺ فَأَعْطَاهُ قَمِيصَهُ وَأَمَرَهُ أَنْ يُكَفِّنَهُ فِيهِ ثُمَّ قَامَ يُصَلِّي عَلَيْهِ فَأَخَذَ عُمَرُ بْنُ الْخَطَّابِ بِثَوْبِهِ فَقَالَ تُصَلِّي عَلَيْهِ وَهْوَ مُنَافِقٌ وَقَدْ نَهَاكَ اللَّهُ أَنْ تَسْتَغْفِرَ لَهُمْ قَالَ إِنَّمَا خَيَّرَنِي اللَّهُ أَوْ أَخْبَرَنِي فَقَالَ {اسْتَغْفِرْ لَهُمْ أَوْ لاَ تَسْتَغْفِرْ لَهُمْ إِنْ تَسْتَغْفِرْ لَهُمْ سَبْعِينَ مَرَّةً فَلَنْ يَغْفِرَ اللَّهُ لَهُمْ} فَقَالَ سَأَزِيدُهُ عَلَى سَبْعِينَ قَالَ فَصَلَّى عَلَيْهِ رَسُولُ اللَّهِ ﷺ وَصَلَّيْنَا مَعَهُ ثُمَّ أَنْزَلَ اللَّهُ عَلَيْهِ {وَلاَ تُصَلِّ عَلَى أَحَدٍ مِنْهُمْ مَاتَ أَبَدًا وَلاَ تَقُمْ عَلَى قَبْرِهِ إِنَّهُمْ كَفَرُوا بِاللَّهِ وَرَسُولِهِ وَمَاتُوا وَهُمْ فَاسِقُونَ}