When Abu Talib was in his death bed, the Prophet ﷺ went to him while Abu Jahl was sitting beside him. The Prophet ﷺ said, "O my uncle! Say: None has the right to be worshipped except Allah, an expression I will defend your case with, before Allah." Abu Jahl and ʿAbdullah bin Umaiya said, "O Abu Talib! Will you leave the religion of ʿAbdul Muttalib?" So they kept on saying this to him so that the last statement he said to them (before he died) was: "I am on the religion of ʿAbdul Muttalib." Then the Prophet said, " I will keep on asking for Allah's Forgiveness for you unless I am forbidden to do so." Then the following Verse was revealed:-- "It is not fitting for the Prophet ﷺ and the believers to ask Allah's Forgiveness for the pagans, even if they were their near relatives, after it has become clear to them that they are the dwellers of the (Hell) Fire." (9.113) The other Verse was also revealed:-- "(O Prophet!) Verily, you guide not whom you like, but Allah guides whom He will ......." (28.56) (Using translation from Bukhārī 3884)
لَمَّا حَضَرَتْ أَبَا طَالِبٍ الْوَفَاةُ دَخَلَ عَلَيْهِ النَّبِيُّ ﷺ وَعِنْدَهُ أَبُو جَهْلٍ وَعَبْدُ اللهِ بْنُ أَبِي أُمَيَّةَ فَقَالَ أَيْ عَمِّ قُلْ لَا إِلَهَ إِلَّا اللهُ كَلِمَةً أُحَاجُّ بِهَا لَكَ عِنْدَ اللهِ فَقَالَ أَبُو جَهْلٍ وَعَبْدُ اللهِ بْنُ أَبِي أُمَيَّةَ يَا أَبَا طَالِبٍ أَتَرْغَبُ عَنْ مِلَّةِ عَبْدِ الْمُطَّلِبِ؟ قَالَ فَلَمْ يَزَالَا يُكَلِّمَانِهِ حَتَّى قَالَ آخِرَ شَيْءٍ كَلَّمَهُمْبِهِ عَلَى مِلَّةِ عَبْدِ الْمُطَّلِبِ فَقَالَ النَّبِيُّ ﷺ لَأَسْتَغْفِرَنَّ لَكَ مَا لَمْ أُنْهَ عَنْكَ فَنَزَلَتْ {مَا كَانَ لِلنَّبِيِّ وَالَّذِينَ آمَنُوا أَنْ يَسْتَغْفِرُوا لِلْمُشْرِكِينَ وَلَوْ كَانُوا أُولِي قُرْبَى مِنْ بَعْدِ مَا تَبَيَّنَ لَهُمْ أَنَّهُمْ أَصْحَابُ الْجَحِيمِ} [التوبة 113] قَالَ وَنَزَلَتْ فِيهِ {إِنَّكَ لَا تَهْدِي مَنْ أَحْبَبْتَ} [القصص 56]