When Abu Talib was on his deathbed, the Prophet ﷺ came in to see him. Abu Jahl and Abdullah bin Abu Umaya were also present.The Prophet ﷺ said, "Uncle, say 'There is no god but Allah,' a word by which I may plead for you before Allah ."Abu Jahl and Abdullah bin Abu Umaya said, "Abu Talib, will you turn away from the religion of Abdul-Muttalib?"They kept speaking to him until the last thing he said to them was that he was upon the religion of Abdul-Muttalib.The Prophet ﷺ said, "I will surely seek forgiveness for you so long as I am not forbidden from doing so."Then the verse was revealed, "It is not for the Prophet and those who believe to ask forgiveness for the polytheists, even if they are close relatives, after it has become clear to them that they are companions of the Hellfire" [Tawbah 9:113].And concerning him was revealed, "Indeed, you do not guide whom you love" [Qasas 28:56].
حدثنا عبد الرزاق حدثنا معمر عن الزهري
لما حضرت أبا طالب الوفاة دخل عليه النبي ﷺ وعنده أبو جهل وعبد الله بن أبي أمية فقال أي عم قل لا إله إلا الله كلمة أحاج بها لك عند الله عز وجل فقال أبو جهل وعبد الله بن أبي أمية يا أبا طالب أترغب عن ملة عبد المطلب قال فلم يزالا يكلمانه حتى قال آخر شيء كلمهم به على ملة عبد المطلب فقال النبي ﷺ لأستغفرن لك ما لم أنه عنك فنزلت {ما كان للنبي والذين آمنوا أن يستغفروا للمشركين ولو كانوا أولي قربى من بعد ما تبين لهم أنهم أصحاب الجحيم} قال فنزلت فيه {إنك لا تهدي من أحببت}
Its isnad is sahih. It is found in Bukhari 8/341, no. 4163, in Fath al-Bari, in the tafsir of "It is not for the Prophet and those who believe to seek forgiveness for the polytheists" [Tawbah 9:113], and in Nasai 4/90, no. 2035, in the book of funerals.