كتاب الإيمان
1  
The Book of Faith
(55)
Chapter: Clarifying the ruling of the action of an unbeliever if he accepts Islam after it
(55)
باب بَيَانِ حُكْمِ عَمَلِ الْكَافِرِ إِذَا أَسْلَمَ بَعْدَهُ ‏‏
Sahih Muslim 123 a

Hakim b. Hizam reported to 'Urwa b. Zubair that he said to the Messenger of Allah:

Do you think that there is any thing for me (of he reward with the Lord) for the deed of religious purification that I did in the state of ignorance? Upon this he (the Messenger of Allah) said to him: You accepted Islam with all the previous virtues that you practised.
حَدَّثَنِي حَرْمَلَةُ بْنُ يَحْيَى، أَخْبَرَنَا ابْنُ وَهْبٍ، قَالَ أَخْبَرَنِي يُونُسُ، عَنِ ابْنِ شِهَابٍ، قَالَ أَخْبَرَنِي عُرْوَةُ بْنُ الزُّبَيْرِ، أَنَّ حَكِيمَ بْنَ حِزَامٍ، أَخْبَرَهُ أَنَّهُ، قَالَ لِرَسُولِ اللَّهِ صلى الله عليه وسلم أَرَأَيْتَ أُمُورًا كُنْتُ أَتَحَنَّثُ بِهَا فِي الْجَاهِلِيَّةِ هَلْ لِي فِيهَا مِنْ شَىْءٍ فَقَالَ لَهُ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ أَسْلَمْتَ عَلَى مَا أَسْلَفْتَ مِنْ خَيْرٍ ‏"‏ ‏.‏ وَالتَّحَنُّثُ التَّعَبُّدُ ‏.‏
Reference : Sahih Muslim 123a
In-book reference : Book 1, Hadith 230
USC-MSA web (English) reference : Book 1, Hadith 222
  (deprecated numbering scheme)