كتاب الإيمان
1  
The Book of Faith
(9)
Chapter: Evidence that the islam of one who becomes muslim on his deathbed is valid, so long as the death thoes have not begun; Abrogation of permission to supplicate for forgiveness for the idolators; Evidence that one who dies an idolator is one of the people of hell and no intervention can save him from that
(9)
باب الدليل على صحة إسلام من حضره الموت ما لم يشرع في النزع وهو الغرغرة ونسخ جواز الاستغفار للمشركين والدليل على أن من مات على الشرك فهو في أصحاب الجحيم ولا ينقذه من ذلك شيء من الوسائل
Sahih Muslim 24 a

It is reported by Sa'id b. Musayyib who narrated it on the authority of his father (Musayyib b. Hazm) that when Abu Talib was about to die, the Messenger of Allah (ﷺ) came to him and found with him Abu Jahl ('Amr b. Hisham) and 'Abdullah b. Abi Umayya ibn al-Mughirah. The Messenger of Allah (ﷺ) said:

My uncle, you just make a profession that there is no god but Allah, and I will bear testimony before Allah (of your being a believer), Abu Jahl and 'Abdullah b. Abi Umayya addressing him said: Abu Talib, would you abandon the religion of 'Abdul-Muttalib? The Messenger of Allah (ﷺ) constantly requested him (to accept his offer), and (on the other hand) was repeated the same statement (of Abu Jahl and 'Abdullah b. Abi Umayya) till Abu Talib gave his final decision and be stuck to the religion of 'Abdul-Muttalib and refused to profess that there is no god but Allah. Upon this the Messenger of Allah remarked: By Allah, I will persistently beg pardon for you till I am forbidden to do so (by God), It was then that Allah, the Magnificent and the Glorious, revealed this verse: " It is not meet for the Prophet and for those who believe that they should beg pardon for the polytheists, even though they were their kith and kin, after it had been made known to them that they were the denizens of Hell" (ix. 113) And it was said to the Messenger of Allah (ﷺ): " Verily thou canst not guide to the right path whom thou lovest. And it is Allah Who guideth whom He will, and He knoweth best who are the guided" (xxviii, 56).
وَحَدَّثَنِي حَرْمَلَةُ بْنُ يَحْيَى التُّجِيبِيُّ، أَخْبَرَنَا عَبْدُ اللَّهِ بْنُ وَهْبٍ، قَالَ أَخْبَرَنِي يُونُسُ، عَنِ ابْنِ شِهَابٍ، قَالَ أَخْبَرَنِي سَعِيدُ بْنُ الْمُسَيَّبِ، عَنْ أَبِيهِ، قَالَ لَمَّا حَضَرَتْ أَبَا طَالِبٍ الْوَفَاةُ جَاءَهُ رَسُولُ اللَّهِ صلى الله عليه وسلم فَوَجَدَ عِنْدَهُ أَبَا جَهْلٍ وَعَبْدَ اللَّهِ بْنَ أَبِي أُمَيَّةَ بْنِ الْمُغِيرَةِ فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ يَا عَمِّ قُلْ لاَ إِلَهَ إِلاَّ اللَّهُ ‏.‏ كَلِمَةً أَشْهَدُ لَكَ بِهَا عِنْدَ اللَّهِ ‏"‏ ‏.‏ فَقَالَ أَبُو جَهْلٍ وَعَبْدُ اللَّهِ بْنُ أَبِي أُمَيَّةَ يَا أَبَا طَالِبٍ أَتَرْغَبُ عَنْ مِلَّةِ عَبْدِ الْمُطَّلِبِ ‏.‏ فَلَمْ يَزَلْ رَسُولُ اللَّهِ صلى الله عليه وسلم يَعْرِضُهَا عَلَيْهِ وَيُعِيدُ لَهُ تِلْكَ الْمَقَالَةَ حَتَّى قَالَ أَبُو طَالِبٍ آخِرَ مَا كَلَّمَهُمْ هُوَ عَلَى مِلَّةِ عَبْدِ الْمُطَّلِبِ ‏.‏ وَأَبَى أَنْ يَقُولَ لاَ إِلَهَ إِلاَّ اللَّهُ ‏.‏ فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ أَمَا وَاللَّهِ لأَسْتَغْفِرَنَّ لَكَ مَا لَمْ أُنْهَ عَنْكَ ‏"‏ ‏.‏ فَأَنْزَلَ اللَّهُ عَزَّ وَجَلَّ ‏{‏ مَا كَانَ لِلنَّبِيِّ وَالَّذِينَ آمَنُوا أَنْ يَسْتَغْفِرُوا لِلْمُشْرِكِينَ وَلَوْ كَانُوا أُولِي قُرْبَى مِنْ بَعْدِ مَا تَبَيَّنَ لَهُمْ أَنَّهُمْ أَصْحَابُ الْجَحِيمِ‏}‏ ‏.‏ وَأَنْزَلَ اللَّهُ تَعَالَى فِي أَبِي طَالِبٍ فَقَالَ لِرَسُولِ اللَّهِ صلى الله عليه وسلم ‏{‏ إِنَّكَ لاَ تَهْدِي مَنْ أَحْبَبْتَ وَلَكِنَّ اللَّهَ يَهْدِي مَنْ يَشَاءُ وَهُوَ أَعْلَمُ بِالْمُهْتَدِينَ‏}‏‏.‏
Reference : Sahih Muslim 24a
In-book reference : Book 1, Hadith 39
USC-MSA web (English) reference : Book 1, Hadith 36
  (deprecated numbering scheme)