مَا كَانَ لِلنَّبِىِّ وَٱلَّذِينَ ءَامَنُوٓا۟ أَن يَسْتَغْفِرُوا۟ لِلْمُشْرِكِينَ وَلَوْ كَانُوٓا۟ أُو۟لِى قُرْبَىٰ مِنۢ بَعْدِ مَا تَبَيَّنَ لَهُمْ أَنَّهُمْ أَصْحَـٰبُ ٱلْجَحِيمِ Qur’an Al-Tawba (9:113)Ma kana lilnnabiyyi waallatheena amanoo an yastaghfiroo lilmushrikeena walaw kanoo olee qurba min baAAdi ma tabayyana lahum annahum ashabu aljaheemi
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.