Answered by Shaykh Amjad Rasheed
Since contemporary physicians say that masturbation is not harmful to the body, and since things are originally permissible, what is the wisdom behind prohibiting masturbation? Is there a spiritual harm in it?
Masturbation with ones own hand, rather than the hand of ones wife, is unlawful. As Imam ash-Shafii noted, the evidence for the prohibition of masturbation is the word of Allah Most High:
those who guard their private parts, save from their wives or [bondwomen] whom their right hands own, for these are not blameworthy. But whoever seeks beyond that, those are the transgressors. (23:5-7)
Masturbation is included in the words of Allah Most High, beyond that. The great Hadith scholar, Abdullah al-Ghumari, compiled the evidences for the prohibition of Masturbation in a small book entitled, al-Istiqsa li Adellati Tahreem il-Istimna .
Whether Masturbation is harmful or not is left to medical doctors to decide. If they say it is harmful, they will emphasize the prohibition of masturbation. If they say it is not harmful, the prohibition will remain in effect. This because the evidence for the prohibition of masturbation is the aforementioned verse whose ruling remains valid. Moreover, the harmfulness to the body is not the basis of the prohibition such that masturbation will be considered unlawful only if it is harmful. Rather, when the ruling of something is confirmed by a reliable evidence as is the present question, it does not matter whether we know the wisdom behind that particular ruling. Although the wisdom behind certain Divine rulings can be concluded, some rulings merely exist to be followed [not to be understood]. This is a general, essential rule that every believer should acknowledge.
As for the question whether masturbation with ones own hand is spiritually harmful or not, the answer is yes; it is. The sacred law closed all the doors leading to the enormity of fornication, which violates one of the Sharias great objectives, namely; the protection of parentage and honor. The harder one trains oneself to become god-fearing and break the sexual desire by lowering ones gaze, leaving masturbation, and avoiding afflictions such as listening to obscene language, the farther he becomes from fornication. But if one gives oneself a free reign to approach fornication by doing the aforementioned, it will be easy for him to fall into it and he would not be able to refrain from it. Thus, the prohibition of masturbation is a means to break the desire of the Nafs (self) and keep it away from fornication. For if one develops the habit of masturbation, one would not be satisfied with it and he would soon seek what is beyond it. The wisdom of the prohibition of masturbation thus appears in spite of the some doctors claim it is not harmful to the body.
(Translated by Abu Muhammad Rahil)