Answered by: Mufti Mohammed Tosir Miah
Before sehri, if a person has sexual intercourse, masturbates or has a wet dream does he have to perform ghusl before sehri time is over, and if he doesn’t would his fast be invalid
Firstly, it should be borne in mind that masturbation is something which is haraam and unlawful in Islam.
Allah states in the Quran: “And those who guard their private parts, except with their spouses or those who are legally in their possession, for in that case they shall not be blamed, however, those who seek to go beyond that in lust are the ones who shall be the transgressors.” (Surah Al Muminun: 5-7)
After praising the believers for guarding their private parts from that which He has made forbidden for them Allah has warned that the transgressors are those who go beyond what is lawful. Imam Qurtubi on commenting on the above verse states that according to the scholars (with the exception of Imam Ahmed ibn Hambal) masturbation is haram. (Tafseer Qurtubi, Vol 12, P98)
Abdullah narrates, “We were with the Prophet while we were young and had no wealth whatever. So Allah’s Apostle said, “O young people! Whoever among you can marry, should marry, because it helps him lower his gaze and guard his modesty (i.e. his private parts from committing illegal sexual intercourse etc.), and whoever is not able to marry, should fast, as fasting diminishes his sexual power.” (Bukhari, 7.4)
If masturbation was permissible, Prophet would have mentioned it at this point. This indicates that masturbation is unlawful because silence at a time of explanation denotes restriction.
With regards to your question, it is not necessary to have a ghusl before the time of sehri finishes. One can have a ghusl afterwards. (Fatawa Darul Uloom Deoband p.496 v.6)
Similarly, Imam Shurunbulali has written in his Nurul Idah ‘If one awakens in the state of janabah (due to a wet dream or sexual intercourse) the fast does not break, even if one remains in this state for the entire day’. (Nurul Idah p.141)
Saaidah Aaiha narrates that ‘the Prophet of Allah would be overtaken by the dawn when he was in a state of major ritual impurity whilst in the state of fasting’. (Sunan Abi Dawud p.330 v.1)
Only Allah Knows Best
Mufti Mohammed Tosir Miah
Darul Ifta Birmingham