The things that make ghusl obligatory are six things. If one of them happens then the Muslim has to do ghusl.
1 – Emission of maniy (semen) from its exit in the male or female, which happens either when one is awake or when one is asleep. If it is emitted when one is awake, there is the condition that one feels pleasure when it is emitted. If it is emitted without pleasure, then ghusl is not required, such as if it is emitted as the result of sickness. If it is emitted when one is asleep, this is what is called ihtilaam (erotic dream) and ghusl is required in all cases because he was not aware (of whether there were feelings of pleasure or not) and he may not experience feelings of pleasure. If a sleeper wakes up and finds traces of maniy, then he must do ghusl. If he has an erotic dream but no maniy comes out of him, and he does not find any trace of it, then he does not have to do ghusl.
2 – Penetration of the penis into the vagina, even if no ejaculation takes place, because of the hadeeth narrated by Muslim and others from the Prophet (peace and blessings of Allaah be upon him): “When a man sits between the four parts (arms and legs of his wife) and has intercourse with her, then ghusl is obligatory.” So ghusl is required of both parties involved by mere virtue of penetration having taken place, even if no ejaculation takes place, because of this hadeeth and because there is scholarly consensus on this point.
3 – According to some scholars, ghusl is required when a kaafir becomes Muslim, because the Prophet (peace and blessings of Allaah be upon him) told some of those who became Muslim to do ghusl. Many scholars think that it is mustahabb, not obligatory, for a kaafir who becomes Muslim to do ghusl because it is not narrated that the Prophet (peace and blessings of Allaah be upon him) told everyone who became Muslim to do that. So it may be understood that it is mustahabb, so as to reconcile the evidence.
4 – Death – the deceased person must be washed, except for the shaheed (martyr) who falls in battle, who is not to be washed.
5 and 6 – Menses and nifaas (post partum bleeding), because the Prophet (peace and blessings of Allaah be upon him) said: “When your menses ends, then do ghusl and pray.” And Allaah says (interpretation of the meaning): “And when they have purified themselves” [al-Baqarah 2:222], referring to menses – they should purify themselves by doing ghusl after their menses ends.
End quote from al-Mulakhkhas al-Fiqhi by Shaykh Saalih al-Fawzaan (may Allaah preserve him).
And Allaah knows best.