If intercourse takes place, i.e., if the tip of the penis disappears in the vagina, then ghusl is obligatory for the man and the woman, even if no semen is emitted, because of the report narrated by al-Bukhaari (291) and Muslim (348) from Abu Hurayrah (may Allaah be pleased with him) from the Prophet (peace and blessings of Allaah be upon him) , who said: “When a man sits between the four parts (arms and legs of his wife) and has intercourse with her, then ghusl is obligatory.”
Muslim added: “Even if he does not ejaculate.”
Ibn Qudaamah (may Allaah have mercy on him) said in al-Mughni (1/131): The fuqaha’ are agreed that ghusl is required in this case, except that it was narrated that Dawood said it is not required. End quote.
It is permissible for a man to enjoy his wife and for a woman to enjoy her husband, however they want, so long as they avoid intercourse at the time of menstruation and anal intercourse. That includes each of them masturbating the other. This comes under the heading of enjoyment that is permitted according to the verse (interpretation of the meaning):
“And those who guard their chastity (i.e. private parts, from illegal sexual acts)
6. Except from their wives or (the slaves) that their right hands possess, ___ for then, they are free from blame”
But if a man masturbates by himself or a woman masturbates by herself, this is haraam. That has been explained in the answer to question no. 329.
And Allaah knows best.