Sayyiduna Abdullah (may Allah be pleased with him) said: A man came to the Prophet (peace and blessings be upon him) and said: "O Messenger of Allah! I dallied with a woman on the far side of Madinah, and I did with her everything short of intercourse. So here I am; pass whatever judgement you wish on me." Sayyiduna Umar (may Allah be pleased with him) said to him: "Allah had concealed you; if only you had concealed yourself." The Prophet (peace and blessings be upon him) gave him no reply. The man got up and left, and the Prophet (peace and blessings be upon him) sent a man after him who called him back, and he recited this verse to him: "Establish prayer at the two ends of the day and in some hours of the night. Indeed, good deeds remove evil deeds. That is a reminder for those who remember." [Surah Hud: 114] A man among the people said: "O Prophet of Allah! Is this for him specifically?" He said: "Rather, for all people."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الحدود / 17085