In the name of Allah, Most Gracious, Most Merciful.
The consensus belief is that taking the bath for sexual impurity is not an obligation for masturbation, or having a sexually arousing dream, unless there is ejaculation. As it has been narrated by way of Sharik bin Abi Nimr, from `Abdur-Rahman bin Abi Sa`id al-Khudri, from Abi Sa`id (may Allah be pleased with him), that the Prophet (peace be upon him) said, “Indeed water [obligation of bathing] is from water [semen ejaculation].” [Muslim (343)]
Also, in the narration of Hisham bin `Urwah, from his father, from Zaynab bint Abi Salamah, from Umm Salamah, who said, “Umm Sulaim came to the Prophet (peace be upon him) and said, “O Messenger of Allah, verily Allah does not shy from the truth, so is it obligatory on a woman to bathe (from sexual impurity) if she sees a sexual dream?” The Prophet (peace be upon him) said, “Yes, if she sees water (discharge).” [Bukhari (130) and Muslim (313)]
The majority of the Hanafis, Malikis and Shafi`is, and a group of Hanbalis, base the obligation of taking a bath on the condition that semen is excreted from the private part. So if, upon feeling the passage of semen and its coming out, one held one’s private part to prevent its excretion and thus it did not come out, then he is not obligated to take a bath, according to the aforementioned hadiths.
However, the Hanbalis are of the opinion that taking a bath is obligatory in this case even if semen did not come out, as the passage of semen from its original place is the sexual impurity referred to in the Qur’an:
“And if you were in a state of sexual impurity, then purify (bathe) yourselves.” [Al-Ma’idah 5:6]
But the correct opinion is the first opinion. So according to it, if you do not ejaculate after practicing what you do to release your sexual passion, then you are not obligated to take a bath.
And Allah knows best.