Jabir bin Abdullah reported,

When Abu Talib died, the Messenger of Allah ﷺ said, "May Allah have mercy on you and forgive you, uncle. I will not cease seeking forgiveness for you until Allah, the Mighty and Majestic, forbids me."So the Muslims began seeking forgiveness for their dead who had died as polytheists, and Allah the Exalted 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 the companions of the Blaze" [Tawbah 9:113].

Azami 3743

Sahih

عن جابر قال

لما مات أبو طالب قال رسول الله ﷺ: رحمك الله وغفر لك يا عم، ولا أزال أستغفر لك حتى ينهاني الله عزوجل فأخذ المسلمون يستغفرون لموتاهم الذين ماتوا وهم مشركون، فأنزل الله تعالى: {ما كان للنبي والذين ءامنوا أن يستغفروا للمشركين ولو كانوا أولي قربى من بعد ما تبين لهم أنهم أصحب الجحيم} [سورة التوبة: ١١٣].

الأعظمي 3743صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Funerals
Chapter
Prayer over the deceased
Section
Prohibition of praying over hypocrites and polytheists and seeking forgiveness for them
Numbering
Jami al-Kamil 3743 (2nd edition)
Azami 3743