Allah (the Supreme) says: ] And who guard their private organs. Except from their wives or the legal bondwomen that they possess, for then there is no blame upon them. So whoever desires more than these two - they are crossing the limits. [Surah Mominun 23:05-07]
Masturbation is also considered as “desiring more” with reference to the Quranic verse above.
Suhail son of Sai’d (may Allah be pleased with them) narrates that the Holy Prophet (Allah’s’ blessings & peace be upon him) said: Whoever gives me the assurance regarding what is between their jaws and their legs (i.e. not to unlawfully use the tongue and the private parts), I give them the assurance of Heaven. (Bukhari)
Abu Hurairah (may Allah be pleased with him) narrates that the Holy Prophet of Allah (Allah’s blessings & peace be upon him) said: Whoever Allah protects, from the evil of what is between their jaws and between their legs, will enter Paradise. [Tirimzi]
Imam Shamsuddin Zahabi (may Allah be pleased with him) narrates a Prophetic narration that, “Seven people are such that Allah has cursed them and He will not even cast a look of mercy upon them on the Day of Judgment. Allah will tell them to enter Hell with the people who are going to Hell, except those who repent.
1. One who performs sodomy.
2. One upon whom the act of sodomy is performed.
3. One who does bad deeds with animals.
4. One who marries his mother or sister.
5. One who masturbates.” (The words of the hadith says these seven people but the narrator lists five - Kitab-ul-Kaba’ir p.48)
Allama Mahmood Aalusi (may Allah be pleased with him) narrates in Ruh-ul-Ma’ni: “Ata’a (may Allah be pleased with him) says that I have heard that on the Day of Judgment a group will be brought in such a state that their hands will be pregnant. I think they are the masturbators.” Allama Aalusi further says: Saéed bin Jubayr (may Allah be pleased with him) narrates that the Holy Prophet (Allah’s blessings & peace be upon him) said: “Allah, the Supreme, will inflict punishment on a group of people because they misused their private parts.” (Ruh-ul-Ma'ni p. 291)
Syedna Anas (may Allah be pleased with him) narrates that the Holy Prophet of Allah (Allah’s blessings & peace be upon him) said: “The person who performs marriage (nikah) with his hands (i.e. masturbates) is cursed.” (Fatawa Razaviyya, Vol. 10, p.80)
Abdullah bin Masood (may Allah be pleased with him) reports that the Holy Prophet (Allah’s blessings & peace be upon him) said: “O group of youth! Whoever from among you can marry should do so because it keeps the gaze low and it protects the private parts. And he who cannot marry should fast because fasting breaks lust.” (Muslim – Book of Marriage)
Mufti Waqar-ud-din Al-Qadri (Hanafi) writes in “Waqar-ul-Fatawa” (Vol. 1, P. 269): “If a person is overpowered by sexual desire so much that there is fear of him becoming involved in adultery or he is not capable of marrying or his wife is so far that he can't go there - then (in such cases) it is hoped there is no punishment for the one doing this (masturbation). It is written in “Durr-e-Mukhtar” (Vol. 2, Pp 109) (by Sheikh Alla’ud Din Muhammed son of Ali Haskiffi, died 1088H): ‘If there is fear of committing adultery then it is hoped that there is no punishment on the one doing this (masturbation)’. Allama (Syed Mohammed Amin Ash-Shaheerba Bin Abideen) Shami, (may Allah’s mercy be upon him, died 1253H) has also argued on this quite a lot and decided that if he does this with the intention of saving himself from committing sin it will not be a sin and if he does it with the intention of enjoyment he will be a sinner.”
The Holy Prophet (Allah’s blessings & peace be upon him) said, "Undoubtedly, virtues wipe away sins". Therefore a masturbator must repent sincerely with an intention that he will never commit it again and do good deeds. According to a Prophetic narration, "The one who repents is like one who has not sinned."