All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
First of all, we ask Allaah to grant us and you wellness and safety from all evil, and to bless us all with guidance, piety, chastity and richness.
We have already issued Fatwa 86017, which clarifies that it is not permissible for the wife to masturbate, and that the absence of her husband does not justify that; so please refer to the above Fatwa. We advise you to supplicate Allaah as much as possible to make you chaste. You should occupy your time with what is beneficial. You should continue fasting, as it is by fasting that one achieves the piety that would deter him from committing what is forbidden.
However, if you find a real need, like the fear of falling into fornication, or getting sick if you do not masturbate, then it would be permissible – in this case – to resort to it. Shaykh Al-Islam Ibn Taymiyyah said: “Masturbating with one’s hand is forbidden according to the majority of the scholars, and it is the more correct opinion of the two views of Imaam Ahmad; and the one who does it is to receive a discretionary punishment. According to the second view, it is disliked and not forbidden, but most of the scholars are of the view that it is not permissible, neither for fear of hardship nor for any other reason. Nonetheless, it was reported from a group of Companions and Taabi‘is (followers of the Companions) that they permitted masturbation for a necessity such as if one fears of Zina (fornication or adultery) and cannot avoid it except by resorting to masturbation, or for fear that if he does not masturbate, he will become sick; this is the view of Imaam Ahmad and others. But if there is no necessity, then I do not know of any scholar who permitted it.” [End of quote]
According to the view that masturbation is permissible for a necessity, we must differentiate between the one who does it for fear of what is forbidden and the one who does it for pleasure. We are concerned that a person might confuse these two matters and be accustomed to this forbidden act and do it for pleasure, and not restrict oneself to what removes the harm from him. The matter involves some prohibitions, so you should be careful.
Finally, it should be noted that it is better for the husband to have his wife with him in his place of residence if possible, and it is not permissible for the husband to be absent from his wife for more than six months without her consent. Please refer to Fatwa 85711.
Allaah Knows best.