كتاب الإيمان
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 25 b

It is narrated on the authority of Abu Huraira that the Messenger of Allah said to his uncle (at the time of his death):

Make a profession of it that there is no god but Allah and I will bear testimony (of your being a Muslim) on the Day of judgment. He (Abu Talib) said: Were it not the fear of the Quraysh blaming me (and) saying that it was the fear of (approaching death) that induced me to do so, I would have certainly delighted your eyes. It was then that Allah revealed: " 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 25b
In-book reference : Book 1, Hadith 42
USC-MSA web (English) reference : Book 1, Hadith 38
  (deprecated numbering scheme)