A man asked, "Messenger of Allah, will we be held accountable for what we did in the days of ignorance?"He replied, "Whoever does well in Islam will not be held accountable for what he did in the days of ignorance, but whoever does evil in Islam will be held accountable for both the former and the latter."
قال رجل: يا رسول الله أنواخذ بما عملنا في الجاهلية؟ قال: من أحسن في الإسلام لم يؤاخذ بما عمل في الجاهلية، ومن أساء في الإسلام أخذ بالأول والآخر.
Bukhari narrated it in the chapter on calling apostates back to Islam, (6921), and Muslim in the book of faith (120), both from the hadith of Mansur, from Amash, from Abu Waail, from Ibn Masud, and he mentioned the hadith, their wording being identical. Here, "wrongdoing" means disbelief and shirk, so whoever associates partners with Allah and disbelieves in Him after having become Muslim will be held accountable for what he did both before Islam and in Islam, otherwise not. This is because Allah, the Exalted, says, "Say to those who disbelieve, if they cease, what has already passed will be forgiven them" [Anfal 8:38], and in the previously mentioned hadith of Amr bin As, "Islam wipes out what came before it."