Praise be to Allaah.
Ghusl is obligatory on men and woman alike when one of the two following things happens:
When the two “circumcised parts” meet, which is penetration, i.e. intercourse – even if there is no ejaculation – because the Prophet (peace and blessings of Allaah be upon him) said: “When the two circumcised parts meet and the tip of the penis disappears, ghusl becomes obligatory, whether ejaculation takes place or not.” (Narrated by Abu Dawood; see Saheeh Sunan Abi Dawood, 209).
2. Ejaculation – even if the two circumcised parts do not meet – whether this happens as a result of manual stimulation or otherwise. The Prophet (peace and blessings of Allaah be upon him) said: “Water is for water” – i.e., ghusl is required when water (meaning semen or sexual fluid) is emitted.
With regard to fasting, it is not essential for a person to do ghusl before Fajr starts in order for his fast to be valid. If he starts a day of fasting whilst he is junub (impure as a result of sexual activity) his fast is till valid. (See: 70 issues related to fasting). But he should hasten to do ghusl so that he can pray Fajr on time.
And Allaah knows best. May Allaah bless our Prophet Muhammad.