When Abu Talib was on the verge of death, the Messenger of Allah ﷺ came to him and found Abu Jahl bin Hisham and Abdullah bin Abu Umaya bin Mughira with him.The Messenger of Allah ﷺ said to Abu Talib, "Uncle, say there is no god except Allah, a word by which I may plead for you before Allah."Abu Jahl and Abdullah bin Abu Umaya said, "Abu Talib, would you turn away from the religion of Abdul-Muttalib?"The Messenger of Allah ﷺ kept putting the words to him, and the two of them kept repeating that same argument, until the last thing Abu Talib said to them was, "He is upon the religion of Abdul-Muttalib." He refused to say there is no god except Allah.The Messenger of Allah ﷺ then said, "By Allah, I will keep asking forgiveness for you unless I am forbidden to do so."So Allah, the Exalted, revealed, "It is not for the Prophet and those who believe to ask forgiveness for the idolaters, even if they are close relatives, after it has become clear to them that they are the companions of the Blaze" [Tawba 9:113]. And concerning Abu Talib, Allah revealed to the Messenger of Allah ﷺ, "You cannot guide whomever you love, but Allah guides whomever He wills, and He knows best those who are guided" [Qasas 28:56].
لما حضر أبا طالب الوفاة جاءه رسول الله ﷺ فوجد عنده أبا جهل بن هشام وعبد الله بن أبي أمية بن المغيرة. قال رسول الله ﷺ لأبي طالب: يا عم، قل لا إله إلا الله، كلمة أشهد لك بها عند الله. فقال أبو جهل وعبد الله بن أبي أمية: يا أبا طالب أترغب عن ملة عبد المطلب؟ فلم يزل رسول الله ﷺ يعرضها عليه. ويعودان بتلك المقالة، حتى قال أبو طالب آخر ما كلمهم: هو على ملة عبد المطلب. وأبى أن يقول: لا إله إلا الله. فقال رسول الله ﷺ: أما والله لأستغفرن لك ما لم أنه عنك. فأنزل الله تعالى {ما كان للنبي والذين ءامنوا أن يستغفروا للمشركين ولو كانوا أولي قربى من بعد ما تبين لهم أنهم أصحب الجحيم} [التوبة: ١١٣] وأنزل في أبي طالب: فقال الرسول الله ﷺ: {إنك لا تهدي من أحببت ولكن الله يهدي من يشاء وهو أعلم بالمهتدين} [ القصص: ٥٦].
Bukhari narrated it in the Tafsir (4772), and Muslim in the Faith (24), both from the hadith of Ibn Shihab, who said, "Saeed bin Musayab informed me, from his father," and he related it.This is what Ibn Abbas, Ibn Umar, Mujahid, Shaybi, Qatada, and others also said, that it was revealed concerning Abu Talib, when the Messenger of Allah ﷺ offered him to say, "There is no god but Allah," but he refused to say it and said, "He remains on the religion of the forefathers." The last thing he said was, "He remains on the religion of Abdul-Muttalib."