During the daytime of Ramadan, fasting Muslims should strive towards controlling their sexual thoughts and desires, and to be more involved in acts of worship in order to reap the benefits of the blessed month of Ramadan.
In his discussion on this issue, Sheikh Ahmad Kutty, a senior lecturer and Islamic scholar stated,
‘Fasting, as can be rightly inferred from the sources, has both outward form and inward spirit: The outward form of fasting entails total abstention from consumption of foods, drink, and sexual gratifications; on the other hand, its inward spirit involves abstaining from all evil thoughts, words, and actions, and being mindful of Allah. Prophet Muhammad (peace and blessings be upon him) has stressed the spiritual aspects of fasting in these words: “Fasting is a shield; therefore while fasting, one should abstain from all kinds of lewdness and obscenities: If, therefore, someone were to revile or rebuke this fasting person, let them not retaliate; rather say, “I am fasting; I am fasting.”
The Prophet (peace and blessings be upon him) further said, “There are many who fast, but they gain nothing out of their fast except hunger and thirst; there are many who pray at night, and yet they gain nothing out of their prayers except sleep deprivation.” In other words, fasting properly involves abstention from all unseemly thoughts, words, and actions.
Therefore, thinking about sex while fasting may nullify the spiritual rewards of fasting, unless they are passing thoughts, over which one has no control, as long as one repels them while being conscious of it.
May Allah help us all to guard our fasts against all breaches, blemishes, and unseemly thoughts, words, and actions, amen.