Narrated 'Ubada bin As-Samit:

While we were with the Prophet, he said, "Will you swear to me the pledge of allegiance that you will not worship any thing besides Allah, will not commit illegal sexual intercourse, and will not steal?" Then he recited the Verse concerning the women. (Sufyan, the subnarrator, often said that the Prophet: added, "Whoever among you fulfills his pledge, will receive his reward from Allah, and whoever commits any of those sins and receives the legal punishment (in this life), his punishment will be an expiation for that sin; and whoever commits any of those sins and Allah screens him, then it is up to Allah to punish or forgive them."

حَدَّثَنَا عَلِيُّ بْنُ عَبْدِ اللَّهِ، حَدَّثَنَا سُفْيَانُ، قَالَ الزُّهْرِيُّ حَدَّثَنَاهُ قَالَ حَدَّثَنِي أَبُو إِدْرِيسَ، سَمِعَ عُبَادَةَ بْنَ الصَّامِتِ ـ رضى الله عنه ـ قَالَ كُنَّا عِنْدَ النَّبِيِّ صلى الله عليه وسلم فَقَالَ ‏"‏ أَتُبَايِعُونِي عَلَى أَنْ لاَ تُشْرِكُوا بِاللَّهِ شَيْئًا وَلاَ تَزْنُوا وَلاَ تَسْرِقُوا ‏"‏‏.‏ وَقَرَأَ آيَةَ النِّسَاءِ ـ وَأَكْثَرُ لَفْظِ سُفْيَانَ قَرَأَ الآيَةَ ـ ‏"‏ فَمَنْ وَفَى مِنْكُمْ فَأَجْرُهُ عَلَى اللَّهِ، وَمَنْ أَصَابَ مِنْ ذَلِكَ شَيْئًا فَعُوقِبَ فَهُوَ كَفَّارَةٌ لَهُ، وَمَنْ أَصَابَ مِنْهَا شَيْئًا مِنْ ذَلِكَ فَسَتَرَهُ اللَّهُ فَهْوَ إِلَى اللَّهِ، إِنْ شَاءَ عَذَّبَهُ وَإِنْ شَاءَ غَفَرَ لَهُ‏}‏ ‏"‏‏.‏ تَابَعَهُ عَبْدُ الرَّزَّاقِ عَنْ مَعْمَرٍ فِي الآيَةِ‏.‏
USC-MSA web (English) reference : Vol. 6, Book 60, Hadith 417
Arabic reference : Book 65, Hadith 4894