Islam has taken a firm and decisive stance against Zina (fornication or adultery). Allah, the Almighty, commands in explicit and unequivocal words: “And come not near unto adultery. Lo! it is an abomination and an evil way.” (Al-Israa’: 32)
Thus, Islam not only prohibits Zina, but also closes all the avenues and means leading to it. This is achieved by prohibiting every step and means leading to stimulating desires, opening ways for illicit sexual relations between men and women, and promoting indecency and obscenity.
In his book Fiqh As-Sunnah, the late Egyptian scholar Sheikh Sayyed Sabiq, may Allah bless his soul, states: “Any illegal sexual intercourse between a man and a woman is subject to a severe punishment prescribed by the Shari’ah. The Fuqahaa’ (Muslim jurists) have unanimously agreed that Zina is constituted by the penetration of the penis into a “forbidden” vagina, deliberately (i.e. not being forced to), and with no doubt of marriage (i.e. marriage that is deemed invalid but the couple don’t know), even if there is no ejaculation.
As for other sexual acts of foreplay which do not result in intercourse, there is no Hadd (prescribed punishment) for it as in the case of Zina. However, the Muslim ruler or judge has the right to give Ta’zeer (disciplinary punishment) for those who indulge in those forbidden activities.
The proof that those acts are not subject to the punishment of Zina is the Hadith reported by Ibn Mas’ood, may Allah be pleased with him, stating that a man came to the Prophet, peace and blessings be upon him, and said: “O Messenger of Allah, I sported with a woman in the outskirts of Madina . . . [and] committed an offence, short of fornication. . . . Kindly deliver verdict on me.” `Umar, may Allah be pleased with him, said to him: “Allah concealed your fault. You had better conceal it yourself also.” The Prophet, peace and blessings be upon him, gave no reply to him, so the man stood up and went away. Thereupon the Prophet, peace and blessings be upon him, sent a person after him to call on him and recite to him: “And keep up prayer in the two parts of the day and in the first hours of the night; surely good deeds take away evil deeds this is a reminder to the mindful.” (Hud 11:115) Following this, the Prophet, peace and blessings be upon him, dismissed the man, telling him: “Allah has exempted you from the imposition of Hadd, or from your sin.” Someone who was present at the time asked the Prophet, peace and blessings be upon him, whether such clemency related only to that individual. “No, but for the people at large,” the Prophet, peace and blessings be upon him, said reassuring all believers. (Reported by Muslim, At-Tirmidhi and Abu Dawood.)”
This does not mean that other behaviors such as kissing, hugging, caressing, heavy petting, etc. are not prohibited, but the requirements needed to justify a harsh punishment of Zina are strict. They are not considered major Zina, but they fit into the category of minor Zina which is also prohibited. Obviously, couples can engage in all these activities without being exposed to witnesses and thus avoid punishment in this life. But they still must answer to Allah, the Almighty, who, in no uncertain terms, admonishes against any sexual contact outside of marriage.
In an authentic Hadith reported by Ahmad, it is narrated that the Prophet, peace and blessings be upon him, said: “The eyes commit Zina, the hands commit Zina and feet commit Zina and the genitals commit Zina.” (Musnad Ahmad, Hadith no. 4258) In another Hadith, he is reported to have said that “the genitals confirm or deny it.” (indicating that starring at opposite sex in a lustful way has a spontaneous effect on the genitals and may induce person to commit Zina).
Thus, in light of the above, it’s clear that masturbation through a prostitute is absolutely Haram (forbidden) though it is not subject to the same punishment of Zina (100 lashes for unmarried person; stoning to death to the married one). A person who indulges in these activities should make sincere repentance to Allah by giving up this sin, feeling regretful for what he has done and ask Allah the Almighty to forgive him.