Allah, may He be glorified and exalted, says (interpretation of the meaning):
“Say to those who have disbelieved, if they cease (from disbelief) their past will be forgiven”
Ibn Katheer (may Allah have mercy on him) said:
Allah, may He be exalted, says to His Prophet (blessings and peace of Allah be upon him): Tell those who have disbelieved that if they give up what they are following of disbelief, dissent and stubbornness, and they enter Islam, obey Allah and repent, He will forgive them what is in the past, i.e., their disbelief, sins and mistakes. End quote. Tafseer Ibn Katheer, 4/48
Al-Bukhaari (6921) and Muslim (120) narrated that Ibn Mas‘ood (may Allah be pleased with him) said: A man said: O Messenger of Allaah, will we be held accountable for what we did during the Jaahiliyyah? He said: “Whoever does good deeds in Islam will not be held accountable for what he did during the Jaahiliyyah, but whoever does evil in Islam will be held accountable for the former and the latter.”
An-Nawawi (may Allah have mercy on him) said: What is meant by doing good here is entering Islam both outwardly and inwardly and becoming a Muslim in the true sense. The one who does that will be forgiven for what he did previously when he was a disbeliever, according to the text of the Holy Qur’an and the saheeh hadeeth, “Islam erases that which came before it” (narrated by Muslim, 121), as well as according to the consensus of the Muslims. End quote.
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
Just as Islam erases what came before it, repentance also erases what came before it. End quote.
Majmoo‘ al-Fataawa, 22/12
Article : ELSUNNAH.wordpress.com