Hadith on Islam: Good deeds before conversion to Islam rewarded

Hakim ibn Hizam reported: He said to the Messenger of Allah, peace and blessings be upon him, “What do you think of the acts of worship I did in the time of ignorance. Will I get anything from them?” The Prophet said, “You have embraced Islam with the good you previously did.”

Source: Ṣaḥīḥ Muslim 123

Grade: Sahih (authentic) according to Muslim

عَنْ حَكِيم بْن حِزَامٍ أَنَّهُ قَالَ لِرَسُولِ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ أَرَأَيْتَ أُمُورًا كُنْتُ أَتَحَنَّثُ بِهَا فِي الْجَاهِلِيَّةِ هَلْ لِي فِيهَا مِنْ شَيْءٍ فَقَالَ لَهُ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ أَسْلَمْتَ عَلَى مَا أَسْلَفْتَ مِنْ خَيْرٍ

123 صحيح مسلم كتاب الإيمان باب بيان حكم عمل الكافر إذا أسلم بعده