I heard a man asking Allah's forgiveness for his parents, though both of them were idolaters.I said to him, "Does a man ask forgiveness for his parents when they are idolaters?"He replied, "Did Ibrahim not ask forgiveness for his father?"So I mentioned this to the Prophet ﷺ, and then there was revealed, "It is not for the Prophet and those who believe to ask forgiveness for the idolaters" down to His words, "he dissociated himself from him" [Tawbah 9:113–114].He said, "when he died." I do not know whether it was Sufyan who said that or Israil, or whether the words "when he died" are part of the hadith itself.
حدثنا يحيى بن آدم حدثنا سفيان عن أبي إسحاق عن أبي الخليل
سمعت رجلا يستغفر لأبويه وهما مشركان فقلت أيستغفر الرجل لأبويه وهما مشركان فقال أولم يستغفر إبراهيم لأبيه فذكرت ذلك للنبي ﷺ فنزلت {ما كان للنبي والذين آمنوا أن يستغفروا للمشركين} إلى قوله {تبرأ منه} قال لما مات فلا أدري قاله سفيان أو قاله إسرائيل أو هو في الحديث لما مات