Abdullah bin Masud reported,

We asked, "Messenger of Allah, will we be held accountable for what we did during the days of ignorance?"The Messenger of Allah ﷺ replied, "Whoever does good in Islam will not be held accountable for what he did during the days of ignorance, but whoever does evil will be held accountable for both the former and the latter."

Ibn Majah 4242

Sahih

حدثنا محمد بن عبد الله بن نمير حدثنا وكيع وأبي عن الأعمش عن شقيق

عن عبد الله قال

قلنا يا رسول الله أنؤاخذ بما كنا نعمل في الجاهلية فقال رسول الله ﷺ من أحسن في الإسلام لم يؤاخذ بما كان في الجاهلية ومن أساء أخذ بالأول والآخر

ابن ماجه 4242صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Asceticism
Chapter
Sins
Numbering
Darussalam 4242
Ibn Majah 4242