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! I have done everything with a woman except intercourse. Upon this, 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."