I heard a man asking forgiveness for his parents, who were both polytheists, so I said to him, "Are you asking forgiveness for your parents when they are polytheists?"He replied, "Did Ibrahim not ask forgiveness for his father when he was a polytheist?"I mentioned this to the Prophet ﷺ, and then the verse was revealed, "It is not for the Prophet and those who believe to ask forgiveness for the polytheists" [Tawbah 9:113].
حدثنا محمود بن غيلان حدثنا وكيع حدثنا سفيان عن أبي إسحق عن أبي الخليل كوفي
سمعت رجلا يستغفر لأبويه وهما مشركان فقلت له أتستغفر لأبويك وهما مشركان فقال أوليس استغفر إبراهيم لأبيه وهو مشرك فذكرت ذلك للنبي ﷺ فنزلت {ما كان للنبي والذين آمنوا أن يستغفروا للمشركين}
[Its chain of transmission is daif]. Nasai also recorded it (4/91, no. 2038, Funerals, chapter on the prohibition of seeking forgiveness for polytheists) through Sufyan Thawri with the same chain, and at the narration in Abu Yaala (1/280, no. 335) he stated explicitly that he had heard it directly. Hakim ruled it sahih (2/335) and Dhahabi agreed with him. Abu Ishaq was a mudallis and narrated it with "an" (without stating direct hearing). The hadith has corroborating narrations in Hakim and elsewhere.On this subject there is also a report from Saeed bin Musayab, from his father [Bukhari, no. 1360, and Muslim, no. 24].