Praise be to Allah.
The Prophet SAWS (peace and blessings of Allaah be upon him) said: “O young men, whoever among you can afford to marry, let him get married, and whoever cannot do that, then he should fast, for it will be a protection for him.” (Narrated by al-Bukhaari, al-Nikaah, 4677)
Ibn Hajar said in Fath al-Baari: With respect to marriage, the scholars have divided men into several categories.
The first is those who have the desire to get married and who have the financial means to do so and who fear for themselves. It is recommended for such a person to get married according to all the scholars; according to one report the Hanbalis said that it is obligatory. The well-known view of Ahmad is that it is not obligatory for the one who is able and has the desire, unless he fears hardship.
Ibn Daqeeq al-‘Eid said: Some of the fuqaha’ divided marriage into five rulings. They said that it is obligatory in cases where there is the fear of hardship, where a man is able for marriage and it is difficult to find a concubine. This was narrated by al-Qurtubi from one of their scholars, namely al-Maaziri, who said: it is obligatory in the case of one who cannot keep away from zinaa otherwise, as stated above.
He said: it is forbidden in the case of one who will not take care of his wife with regard to intercourse and spending on her, who is not able for marriage and has no desire for it. Al-Safaareeni said: the poor man who cannot spend on a wife and has no income, and has no desire – in this case it is said that marriage is makrooh for him, because he is cannot afford it and he cannot provide his wife with enjoyment to protect her, and he has no need for it.
See Ghidhaa’ al-Albaab, vol. 2, p. 434
‘Iyaad said: it is recommended in the case of everyone who hopes for offspring even if he has no desire for intercourse, because the Prophet (peace and blessings of Allaah be upon him) said: “I will be proud of your great numbers.” And because of the encouragement for marriage and the commands to marry. The same applies to the one who has any desire for other kinds of enjoyment of women besides intercourse. But in the case of one who is sterile or has no desire for women or for physical pleasure, marriage is permissible for him if the woman knows and accepts that.
The hadeeth indicates that masturbation is haraam, because if it were prescribed the Prophet (peace and blessings of Allaah be upon him) would have indicated that. See also Question no. 329
If a person is patient in abstaining from that which Allaah has forbidden and gives it up because he is seeking the pleasure of Allaah, then Allaah will reward him abundantly on the Day of Resurrection, because whoever gives up something for the sake of Allaah, Allaah will compensate him with something better.
And Allaah says, describing the believers (interpretation of the meaning):
“And those who guard their chastity (i.e. private parts, from illegal sexual acts)” [al-Mu’minoon 23:5]
The Muslim has to follow the path prescribed by Islam, as taught by the Messenger of Allaah (peace and blessings of Allaah be upon him), which is fasting. May Allaah protect you and us from falling into haraam. And Allaah knows best.