All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
There is no doubt that seeking forgiveness for the dead Muslim is legitimate, even if he did not repent for his sins. So the disobedient believers who died without repenting for their sins are subject to Allah’s will; if He wills, He forgives their sins, and if He wills, He punishes them. But eventually they will be admitted to Jannah (Paradise), contrary to the belief of some innovators that those Muslims who committed major sins would abide in Hell for eternity.
Allah the Almighty says (what means): {Indeed, Allah does not forgive association with Him, but He forgives what is less than that for whom He wills. And he who associates others with Allah has certainly fabricated a tremendous sin.} [Quran 4: 48]
Ibn Taymiyyah said in Majmoo’ al-Fatawa: “Ahl as-Sunnah inferred from this verse the permissibility of forgiveness for those who committed major sins in general terms, unlike the view of the Kharijites and Mu’tazilah who obligate the execution of the warning (punishment) against those who commit major sins.”
It is reported in the two authentic books of Al-Bukhari and Muslim from Abu Dharr that the Prophet, sallallaahu`alayhi wa sallam, said, “Gabriel came to me and gave me the tidings: Verily he who died amongst your Ummah without associating anything with Allah would enter Paradise.” I (the narrator) said: “Even if he committed adultery and theft.” He (the Prophet) said: “(Yes), even if he committed adultery and theft.”
The one who is forbidden to ask forgiveness for is the one who has died as a disbeliever, as Allah the Almighty says (what means): {It is not for the Prophet and those who have believed to ask forgiveness for the polytheists, even if they were relatives, after it has become clear to them that they are companions of Hellfire.} [Quran 9:113]
Allah knows best.