"You who believe, fasting has been prescribed for you as it was prescribed for those before you" [Baqarah 2:183]. During the time of the Prophet ﷺ, once people had prayed the night prayer, food, drink, and intimacy with women became forbidden to them, and they would fast until the following night.A man wronged himself and had relations with his wife after he had prayed the evening prayer and had not broken his fast. So Allah willed to make this an ease for those who remained, a concession and a benefit, and the Glorified One said, "Allah knows that you used to deceive yourselves" [Baqarah 2:187], to the end of the verse.This was among the matters by which Allah brought benefit to people, granting them concession and ease.
حدثنا أحمد بن محمد بن شبويه حدثني علي بن حسين بن واقد عن أبيه عن يزيد النحوي عن عكرمة
{يا أيها الذين آمنوا كتب عليكم الصيام كما كتب على الذين من قبلكم} فكان الناس على عهد النبي ﷺ إذا صلوا العتمة حرم عليهم الطعام والشراب والنساء وصاموا إلى القابلة فاختان رجل نفسه فجامع امرأته وقد صلى العشاء ولم يفطر فأراد الله عز وجل أن يجعل ذلك يسرا لمن بقي ورخصة ومنفعة فقال سبحانه {علم الله أنكم كنتم تختانون أنفسكم} الآية وكان هذا مما نفع الله به الناس ورخص لهم ويسر