It is narrated from Sayyiduna Ibn Mas'ud (may Allah be pleased with him) that once a man came to the Prophet (peace and blessings be upon him) and said: O Messenger of Allah (peace and blessings be upon him)! I met a woman in a garden, I pulled her towards myself, embraced her, kissed her, and did everything with her except for intercourse. The Prophet (peace and blessings be upon him) remained silent for a while, then Allah revealed this verse: «﴿وَأَقِمِالصَّلَاةَطَرَفَيِالنَّهَارِوَزُلَفًامِنَاللَّيْلِإِنَّالْحَسَنَاتِيُذْهِبْنَالسَّيِّئَاتِذَلِكَذِكْرَىلِلذَّاكِرِينَ﴾»[هود : 114] "Establish prayer at the two ends of the day and at some hours of the night. Indeed, good deeds erase bad deeds. That is a reminder for those who remember." Sayyiduna Umar (may Allah be pleased with him) asked: O Messenger of Allah (peace and blessings be upon him)! Is this command specific to him? He replied: "No! Rather, this ruling is for every person of my Ummah who commits such an act."
Hadith Referenceمسند احمد / مسند المكثرين من الصحابة / 4250
Hadith Gradingحکم دارالسلام:حديث صحيح، م: 2763، وهذا إسناد حسن من أجل ابن حرب.