Praise be to Allah.
Shaykh ‘Abd al-‘Azeez ibn Baaz (may Allaah have mercy on him) said: There is no contradiction between them – praise be to Allaah. In the first verse Allaah is telling His slaves that any sin less than shirk (associating others in worship with Him) is subject to His will: He may forgive it by His grace, or He may punish the person who dies in sin in a way commensurate with his sin, because he transgressed the sacred limits of Allaah and did that which deserves the wrath of Allaah. But the mushrik (one who associates others with Allaah) cannot be forgiven, rather he is doomed to Hell for eternity, to abide therein forever, if he dies in shirk – we seek refuge with Allaah from that.
With regard to the second verse, this is a warning to one who kills a person unlawfully, that he will be punished and that Allaah is angry with him for that. Hence Allaah says (interpretation of the meaning):
“And whoever kills a believer intentionally, his recompense is Hell to abide therein; and the Wrath and the Curse of Allaah are upon him, and a great punishment is prepared for him”
What this means is that this is the punishment if Allaah punishes him, and he deserves that; if Allaah forgives him then He is All-forgiving. He may be punished with what Allaah mentions of a period of time spent in Hell, then Allaah will bring him forth from the Fire. This is a temporary abiding in Hell, which is not like the abiding of the kuffaar. For abiding is of two types, eternal abiding which never ends, which is the abiding of the kuffaar in Hell, as Allaah says concerning them (interpretation of the meaning):
“Thus Allaah will show them their deeds as regrets for them. And they will never get out of the Fire”
And Allaah says in Soorat al-Maa’idah (interpretation of the meaning):
“They will long to get out of the Fire, but never will they get out therefrom; and theirs will be a lasting torment”
With regard to sinners, such as the one who kills a person unlawfully, the one who commits adultery, the one who disobeys his parents, the one who consumes riba, the one who drinks alcohol and so on, if they die in their sin and they are Muslims, then they are subject to the will of Allaah, as He says (interpretation of the meaning):
“but He forgives except that (anything else) to whom He wills…”
So if He wills, He will forgive them because of the righteous deeds with which they died, such as their believing in Allaah alone (Tawheed), their sincerity towards Allaah and their being Muslims, or because of the intercession of those who intercede for them, as well as their Tawheed and sincerity.
Or He may punish them and not forgive them, so He will punish them by causing them to enter Hell and tormenting them therein, in a manner commensurate with their sin, then he will bring them forth therefrom, as is mentioned in many ahaadeeth from the Messenger of Allaah (peace and blessings of Allaah be upon him), who said that he will intercede for the sinners among his ummah, and that Allaah will set a limit for that several times, so he will intercede and bring forth a number of them by Allaah’s leave, then he will intercede again and again and again; he (peace and blessings of Allaah be upon him) will intercede four times. Similarly the angels, the believers and the children who died before reaching the age of adolescence and before their parents died, will all intercede and Allaah will bring forth whomever He wills from the Fire because of their intercession. Then some sinners among those who believed in Tawheed and Islam will be left in Hell, and Allaah will bring them forth by His grace and mercy without any intercession, then there will be no one left in Hell except those whom the Qur’aan has ruled will abide therein forever, namely the kuffaar.
Thus the questioner will understand how to reconcile these two verses, and similar texts and the ahaadeeth which promise Paradise to those who die in Islam, except those whom Allaah wishes to punish for their sin. And He is the most Wise and most Just in that; He rules as He wills and does what He wants.
And there are some whom Allaah will not punish, by His grace, for many reasons, such as righteous deeds and because of the intercession of the intercessors, and above all that because of His Mercy and Grace.