Answered by Shaykh Yusuf Weltch
What should a person do if he has romantic or sexual thoughts while fasting? Is he required to take ghusl and continue fasting, or does he have to make up for the day?
In the Name of Allah, the Most Merciful and Compassionate
Merely having a sexual thought does not affect the validity of the fast and does not require a ritual bath (ghusl). [Maydani, al-Lubab fi Sharh al-Kitab]
However, if because of the thought one ejaculated, the ritual bath becomes obligatory; in this case, the fast still continues, as long as one did not physically cause the ejaculation by an action, such as touching. Such an issue is similar to having a nocturnal ejaculation during Ramadan: the fast remains intact. [Ibid.]
Hope this helps
Allah knows best
[Shaykh] Yusuf Weltch
Checked and Approved by Shaykh Faraz Rabbani
Shaykh Yusuf Weltch is a teacher of Arabic, Islamic law, and spirituality. After accepting Islam in 2008, he then completed four years at the Darul Uloom seminary in New York where he studied Arabic and the traditional sciences. He then traveled to Tarim, Yemen, where he stayed for three years studying in Dar Al-Mustafa under some of the greatest scholars of our time, including Habib Umar Bin Hafiz, Habib Kadhim al-Saqqaf, and Shaykh Umar al-Khatib. In Tarim, Shaykh Yusuf completed the memorization of the Qur’an and studied beliefs, legal methodology, hadith methodology, Qur’anic exegesis, Islamic history, and a number of texts on spirituality. He joined the SeekersGuidance faculty in the summer of 2019.