Praise be to Allah, and peace and blessings be upon our Master, the Messenger of Allah.
The Hellfire is the eternal abode for the wretched who died in a state of disbelief, as Allah the Almighty said {what means}: “Indeed, Allah has cursed the disbelievers and prepared for them a blazing fire, abiding therein forever; they will find no protector or helper.” [Al-Ahzab, 64-65]. Moreover, Allah, Glorified and Exalted, said {what means}: “They will wish to get out of the Fire, but never will they get out from it, and theirs will be a lasting punishment.” [Al-Ma'idah, 37].
As for those believers who enter Hell after having died in a state of Islam, they will be punished according to their sins, but then they will be taken out of Hell by the mercy and grace of Allah, and through the intercession of the best of all messengers, Muhammad (peace and blessings be upon him). Abu Sa'id Al-Khudri (may Allah be pleased with him) narrated that the Prophet (peace and blessings be upon him) said: "The people of Paradise will enter Paradise, and the people of Hell will enter Hell. Then Allah, The Almighty, will say: 'Bring out whoever has in their heart the weight of a mustard seed of faith." (Reported by Bukhari & Muslim).
Abu al-Hasan al-Ash'ari (may Allah have mercy on him) said: "The Mu'tazilites and the Kharijites believed in the eternal punishment of Fasiq (Disobedient to Allah and rebellious against His commands), meaning that whoever enters Hell will not be taken out of it. However, the people of Sunnah and righteousness say that Allah will remove the monotheistic people of the Qibla (All Muslims who believe in the Ka'ba as their qibla.) from Hell and will not leave them there forever ." (From Maqalat al-Islamiyyin 1/474). And Allah The Almighty knows best.