مَا كَانَ لِلنَّبِىِّ وَٱلَّذِينَ ءَامَنُوٓا۟ أَن يَسْتَغْفِرُوا۟ لِلْمُشْرِكِينَ وَلَوْ كَانُوٓا۟ أُو۟لِى قُرْبَىٰ مِنۢ بَعْدِ مَا تَبَيَّنَ لَهُمْ أَنَّهُمْ أَصْحَـٰبُ ٱلْجَحِيمِ Qur’an Al-Tawba (9:113)M a k a na li l nnabiyyi wa a lla th eena a manoo an yastaghfiroo lilmushrikeena walaw k a noo olee qurb a min baAAdi m a tabayyana lahum annahum a s ha bu alja h eem i
As is obvious from the sequence, this prohibition relates to the dead among such sinners - i.e., those who have died without repentance (Zamakhshari, Razi) - and not to those who are still living: for "a prayer for forgiveness in respect of a living [sinner]...amounts to asking God that He grace him with His guidance...and this is permissible" (Manar XI, 60).
This is usually understood to refer to the prayer for the dead, (1) if they died unrepentant after Islam was preached to them, (2) if they actively resisted or opposed the Faith to the last.