Sahih al-Bukhari, Hadith 4670

Narrated Ibn `Abbas: When `Abdullah bin 'Ubai died, his son `Abdullah bin `Abdullah came to Allah's Messenger and asked him to give him his shirt in order to shroud his father in it. He gave it to him and then `Abdullah asked the Prophet to offer the funeral prayer for him (his father). Allah's Messenger got up to offer the funeral prayer for him, but `Umar got up too and got hold of the garment of Allah's Messenger and said, "O Allah's Messenger Will you offer the funeral prayer for him though your Lord has forbidden you to offer the prayer for him" Allah's Messenger said, "But Allah has given me the choice by saying: '(Whether you) ask forgiveness for them, or do not ask forgiveness for them; even if you ask forgiveness for them seventy times..' (9.80) so I will ask more than seventy times." `Umar said, "But he (`Abdullah bin 'Ubai) is a hypocrite!" However, Allah's Messenger did offer the funeral prayer for him whereupon Allah revealed: 'And never (O Muhammad) pray for anyone of them that dies, nor stand at his grave.' (9.84)

حَدَّثَنَا عُبَيْدُ بْنُ إِسْمَاعِيلَ، عَنْ أَبِي أُسَامَةَ، عَنْ عُبَيْدِ اللَّهِ، عَنْ نَافِعٍ، عَنِ ابْنِ عُمَرَ ـ رضى الله عنهما ـ قَالَ لَمَّا تُوُفِّيَ عَبْدُ اللَّهِ جَاءَ ابْنُهُ عَبْدُ اللَّهِ بْنُ عَبْدِ اللَّهِ إِلَى رَسُولِ اللَّهِ صلى الله عليه وسلم فَسَأَلَهُ أَنْ يُعْطِيَهُ قَمِيصَهُ يُكَفِّنُ فِيهِ أَبَاهُ فَأَعْطَاهُ، ثُمَّ سَأَلَهُ أَنْ يُصَلِّيَ عَلَيْهِ، فَقَامَ رَسُولُ اللَّهِ صلى الله عليه وسلم لِيُصَلِّيَ فَقَامَ عُمَرُ فَأَخَذَ بِثَوْبِ رَسُولِ اللَّهِ صلى الله عليه وسلم فَقَالَ يَا رَسُولَ اللَّهِ تُصَلِّي عَلَيْهِ وَقَدْ نَهَاكَ رَبُّكَ أَنْ تُصَلِّيَ عَلَيْهِ فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ إِنَّمَا خَيَّرَنِي اللَّهُ فَقَالَ ‏{‏اسْتَغْفِرْ لَهُمْ أَوْ لاَ تَسْتَغْفِرْ لَهُمْ إِنْ تَسْتَغْفِرْ لَهُمْ سَبْعِينَ مَرَّةً‏}‏ وَسَأَزِيدُهُ عَلَى السَّبْعِينَ ‏"‏‏.‏ قَالَ إِنَّهُ مُنَافِقٌ‏.‏ قَالَ فَصَلَّى عَلَيْهِ رَسُولُ اللَّهِ صلى الله عليه وسلم فَأَنْزَلَ اللَّهُ ‏{‏وَلاَ تُصَلِّ عَلَى أَحَدٍ مِنْهُمْ مَاتَ أَبَدًا وَلاَ تَقُمْ عَلَى قَبْرِهِ‏}‏‏.‏

sunnah.com