عَنِ ابْنِ مَسْعُودٍ رَضِيَ اللَّهُ عَنْهُ، قَالَ: قَالَ رَجُلٌ: يَا رَسُولَ اللَّهِ، أَنُؤَاخَذُ بِمَا عَمِلْنَا فِي الجَاهِلِيَّةِ؟ قَالَ: «مَنْ أَحْسَنَ فِي الإِسْلاَمِ لَمْ يُؤَاخَذْ بِمَا عَمِلَ فِي الجَاهِلِيَّةِ، وَمَنْ أَسَاءَ فِي الإِسْلاَمِ أُخِذَ بِالأَوَّلِ وَالآخِرِ».
[صحيح] - [متفق عليه]
المزيــد ...

Ibn Mas‘ūd (may Allah be pleased with him) said: “A man said, ‘O Messenger of Allah! Shall we be punished for what we did in Jāhiliyyah (Pre-islamic period)?’ The Prophet (may Allah’s peace and blessings be upon him) said: ‘Whoever does good in Islam will not be punished for what he did in Jāhiliyyah and whoever does evil after embracing Islam will be punished for his former and later (bad deeds).’”
[Sahih/Authentic] - [Al-Bukhari and Muslim]

Explanation

A man asked the Prophet (may Allah’s peace and blessings be upon him) about the sins and bad deeds they committed during Jāhiliyyah, and whether they would be punished for them or not. The Prophet (may Allah’s peace and blessings be upon him) said that whoever is good after embracing Islam, which entails holding fast to his religion and abandoning acts of disobedience, then he will not be recompensed for the sins he did before entering Islam, whether they were major sins, like murder and unlawful sexual intercourse, or minor ones. But whoever does evil after embracing Islam, that is to commit apostasy, then he will be recompensed for the bad deeds he committed before and after becoming a Muslim. This is the correct meaning of evil-doing. If it is said that it means committing sins and misdeeds, then such apparent indication goes against the view that Islam wipes away the sins committed before it, as unanimously agreed upon by the Muslim Ummah. This is stated in a Hadīth narrated by Muslim. Furthermore, Allah Almighty says: {Say to those who disbelieve that if they desist, their past will be forgiven, but if they persist, then they have a precedent in those who have passed before them.} It could be interpreted to mean that such a person should be reproached and censured for his former disbelief, by saying to him: “Did you not do such-and-such when you were a disbeliever? Why were you not prevented by your embracing of Islam from going back to such a sin after you became a Muslim?” Then he should be subject to punishment for the sin he committed after being a Muslim. It is also said that doing evil could mean that his belief in Islam is deficient, or his faith is not pure by being a hypocrite or the like. The first interpretation is the approved one.

Translation: Spanish Urdu Kurdish Swahili
View Translations
1: It shows the keen interest of the Companions (may Allah be pleased with them) for the deeds and their acceptance.
2: It encourages doing good in Islam and abandoning disobedience.
3: An apostate will be recompensed for the deeds he does before and after Islam.