Abdullah bin Masud reported,

Some people said to the Messenger of Allah ﷺ, "Messenger of Allah, will we be held accountable for what we did during the days of ignorance?"He replied, "Whoever among you does well in Islam will not be held accountable for it, but whoever does evil will be held accountable for his deeds in both the days of ignorance and in Islam."

Muslim 318

Sahih

حدثنا عثمان بن أبي شيبة حدثنا جرير عن منصور عن أبي وائل

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

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

مسلم 318صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Faith
Chapter
Whether one is held accountable for deeds of the pre-Islamic era
Numbering
Darussalam 318
Muslim 318