[Machine] People used to fast during Ramadan, and when a man woke up after sleeping, it was forbidden for him to have food, drink, or have relations with women, until he broke his fast the next morning. Omar ibn Al-Khattab returned from the Prophet ﷺ one night, having spent the night with him, and found his wife sleeping. He wanted to approach her but she said, "I am sleeping." He said, "You did not sleep," and then had relations with her. Ka'b ibn Malik did the same thing. The next day, Omar went to the Prophet ﷺ and informed him of what happened. Allah then revealed the verse, "Allah knew that you used to deceive yourselves, so He accepted your repentance and forgave you" (Surah Al-Baqarah, 2:187).
كَانَ النَّاسُ فِي رَمَضَانَ إِذَا صَامَ الرَّجُلُ فَأَمْسَى فَنَامَ حَرُمَ عَلَيْهِ الطَّعَامُ وَالشَّرَابُ وَالنِّسَاءُ حَتَّى يُفْطِرَ مِنَ الْغَدِ فَرَجَعَ عُمَرُ بْنُ الْخَطَّابِ مِنْ عِنْدِ النَّبِيِّ ﷺ ذَاتَ لَيْلَةٍ وَقَدْ سَهِرَ عِنْدَهُ فَوَجَدَ امْرَأَتَهُ قَدْ نَامَتْ فَأَرَادَهَا فَقَالَتْ إِنِّي قَدْ نِمْتُ قَالَ مَا نِمْتِ ثُمَّ وَقَعَ بِهَا وَصَنَعَ كَعْبُ بْنُ مَالِكٍ مِثْلَ ذَلِكَ فَغَدَا عُمَرُ إِلَى النَّبِيِّ ﷺ فَأَخْبَرَهُ فَأَنْزَلَ اللهُ تَعَالَى {عَلِمَ اللهُ أَنَّكُمْ كُنْتُمْ تَخْتَانُونَ أَنْفُسَكُمْ فَتَابَ عَلَيْكُمْ وَعَفَا عَنْكُمْ} [البقرة 187]