“Masturbation is generally considered forbidden in Islam since it is deemed to fall under the category of sexual satisfaction outside the framework of marriage.
According to the Qur’an, those who seek fulfillment outside the framework of marriage are deemed transgressors. Referring to this, Allah Almighty says: “Those who guard their sexual organs except with their spouses or those whom their right hands possess, for (with regard to them) they are without blame. But those who crave something beyond that are transgressors.” (Al-Mu'minoon:5-7)
While explaining this verse, one often finds the commentators listing masturbation under the list of the forbidden categories of sexual fulfillment.
What we have stated above is the generally accepted view. However, according to some scholars, if a person is so tormented by his intense sexual desire or craving that he fears falling into Zina (fornication), in such a case, masturbation is permitted as the lesser of the two evils. His case may be compared to that of a person who is permitted to eat pork because of fear of death by starvation.
However, having mentioned the above, we must state that one hardly needs to resort to it when we recognize the relatively flexible approach towards marriage that Islam adopts. Unfortunately, against the clear teachings of Islam, marriage has been rendered another difficult process today due to warped customs and conventions and undue expectations. When we approach marriage from the point of view of pristine Islam, we shall find less and less people being forced to exercise the above type of exceptional rulings.”
"In Islam marriage is a partnership based on mutual rights and obligations. It is, therefore, important that both spouses try their best to be considerate and sensitive towards the needs and feelings of one another and do their best to satisfy each other within the bounds of Islam.
Sexual fulfillment is an important part of the mutual obligations of husband and wife. Your husband definitely needs to be aware of his duty towards you in this respect, and take it seriously. Just as you have a duty to satisfy him, he is also obligated to satisfy you.
Should he be suffering from a sexual dysfunction, he is required to seek professional advice in order for your marriage to be a happy one. If he cannot satisfy you through sexual intercourse, he is perfectly justified in satisfying you through other avenues; he could very well masturbate you; if he were to do this, he is working within the perfect limits of Islam; his doing it on you is different from you doing it on yourself. A person masturbating on himself/herself is not allowed in Islam except in dire necessity where one fears falling into adultery; marriage is intended in Islam to be a shield against that. So being married, you should never be forced into this option.
If in spite of your best efforts to convince your husband, he still remains insensitive to your needs in this respect, you are justified in taking whatever steps are necessary in terminating your marriage, if you are unable to tolerate it. This is definitely one of the valid grounds for divorce in Islam. This can be inferred from the following incident reported in the authentic traditions; once a woman appeared before the Prophet (peace and blessings be upon him) and told him, I cannot find fault with my husband in matters of religion or character; but he is a total misfit (as far as sexual function is concerned). The Prophet (peace and blessings be upon him) we are told, ordered a termination of the marriage."
(Sheikh Ahmad Kutty)
"The majority of Muslim scholars consider masturbation haram (unlawful). Imam Malik bases his judgment on the verse: 'Those who guard their sexual organs except with their spouses or those whom their right hands possess, for (with regard to them) they are without blame. But those who crave something beyond that are transgressors.' (Al-Mu'minoon:5-7)
Imam Malik argued that the masturbator is one of those who ‘crave something beyond that.’
On the other hand, it is reported that Imam Ahmad Ibn Hanbal regarded semen as an excretion of the body like other excrete, and permitted its expulsion the same way blood letting is permitted. Ibn Hazm holds the same view. However, the Hanbali jurists permit masturbation only under two conditions: first, the fear of committing fornication or adultery, and second, not having the means to marry.
We are inclined to accept the opinion of Imam Ahmad in a situation in which there is sexual excitation and danger of committing the haram [adultery]. For example, a young man has gone abroad to study or work, thereby encountering many temptations which he fears he will be unable to resist, may resort to this method of relieving sexual tension provided he does not do it excessively or make it a habit. Yet, better than this is the Prophet's advice to the Muslim youth who is unable to marry, namely, that he seeks help through frequent fasting, for fasting nurtures will-power, teaches control of desires, and strengthens the fear of Allah. The Prophet (peace and blessings be upon him) is reported to have said, 'O youth, whoever of you is able to marry, let him marry, for it spares one looking at what one should not, or lapsing in adultery. And if he cannot marry, let him observe fasting, for it is a shield against evil.' (Reported by Muslim.)"
(Sheikh Yusuf Al-Qaradawi )