When death approached Abu Talib, the Prophet ﷺ came in to see him while Abu Jahl and Abdullah bin Abu Umaya were there with him. The Prophet ﷺ said, "Uncle, say 'There is no god but Allah,' a statement by which I may plead for you before Allah."Abu Jahl and Abdullah bin Abu Umaya said, "Abu Talib, are you turning away from the religion of Abdul-Muttalib?"The Prophet ﷺ said, "I will surely seek forgiveness for you so long as I am not forbidden to do so." Then this verse was revealed, "It is not for the Prophet and those who believe to ask forgiveness for the polytheists, even if they were relatives, after it has become clear to them that they are companions of the Hellfire." [Tawba 9:113]
لما حضر أبا طالب الوفاة دخل عليه النبي ﷺ وعنده أبو جهل وعبد الله بن أبي أمية فقال النبي ﷺ: أي عم قل لا إله إلا الله أحاج لك بها عند الله فقال أبو جهل وعبد الله بن أبي أمية: يا أبا طالب! أترغب عن ملة عبد المطلب؟ فقال النبي ﷺ: لأستغفرن لك ما لم أنه عنك فنزلت: {ما كان للنبي والذين ءامنوا أن يستغفروا للمشركين ولو كانوا أولي قربى من بعد ما تبين لهم أنهم أصحب الجحيم} [سورة التوبة: ١١٣].
Bukhari narrated it in the tafsir (4675), and Muslim in faith (24/40), both from Ishaq bin Ibrahim, who said, Abdul-Razzaq narrated to us, Mamar informed us, from Zuhri, from Saeed bin Musayab, from his father, and he related it. The wording given is that of Bukhari.There are other hadiths on this subject mentioned in the book of funerals.