A man came to the Prophet ﷺ and said, "I was intimate with a woman from the far end of Medina, and I took from her everything short of intercourse. Here I am, so impose on me whatever penalty you wish."Umar said, "Allah had concealed your sin. You should have concealed it yourself."The Prophet ﷺ gave him no reply, so the man left. Then the Prophet ﷺ sent someone after him to call him back, and he recited to him, "And establish prayer at the two ends of the day and during parts of the night. Indeed, good deeds drive away bad deeds. That is a reminder for those who remember" [Hud 11:114].A man from the gathering asked, "Messenger of Allah, is this for him alone or for all people?"He replied, "For all people."
حدثنا مسدد بن مسرهد حدثنا أبو الأحوص حدثنا سماك عن إبراهيم عن علقمة والأسود قالا
جاء رجل إلى النبي ﷺ فقال إني عالجت امرأة من أقصى المدينة فأصبت منها ما دون أن أمسها فأنا هذا فأقم علي ما شئت فقال عمر قد ستر الله عليك لو سترت على نفسك فلم يرد عليه النبي ﷺ شيئا فانطلق الرجل فأتبعه النبي ﷺ رجلا فدعاه فتلا عليه {وأقم الصلاة طرفي النهار وزلفا من الليل} إلى آخر الآية فقال رجل من القوم يا رسول الله أله خاصة أم للناس كافة فقال للناس كافة
Muslim narrated it in the chapter "The Book of Repentance, the chapter on Allah's saying, 'Indeed, good deeds erase bad deeds,'" hadith no. 2763, from the hadith of Abu Ahwas, with this wording. Bukhari also narrated it, hadith no. 526, through another route from Abdullah bin Masud, with this wording.