Sunan Ibn Majah, Volume 5, Book 37, Hadith 4242 (DarusSalam)

It was narrated that ‘Abdullah said: “We said: ‘O Messenger of Allah, will we be taken to task for what we did in the Ignorance period?’ The Messenger of Allah said: ‘Whoever does good in Islam (i.e., after becoming a Muslim) he will not be taken to task for what he did in the Ignorance period, but whoever does evil (i.e., after entering Islam) he will be taken to task for both the former and the latter.’”

حَدَّثَنَا مُحَمَّدُ بْنُ عَبْدِ اللَّهِ بْنِ نُمَيْرٍ، حَدَّثَنَا وَكِيعٌ، وَأَبِي، عَنِ الأَعْمَشِ، عَنْ شَقِيقٍ، عَنْ عَبْدِ اللَّهِ، قَالَ قُلْنَا ‏:‏ يَا رَسُولَ اللَّهِ أَنُؤَاخَذُ بِمَا كُنَّا نَفْعَلُ فِي الْجَاهِلِيَّةِ فَقَالَ رَسُولُ اللَّهِ ـ صلى الله عليه وسلم ـ ‏:‏ ‏ "‏ مَنْ أَحْسَنَ فِي الإِسْلاَمِ لَمْ يُؤَاخَذْ بِمَا كَانَ فِي الْجَاهِلِيَّةِ وَمَنْ أَسَاءَ أُخِذَ بِالأَوَّلِ وَالآخِرِ ‏" ‏ ‏.‏

sunnah.com