All praise is due to Allāh , the Lord of the Worlds. The Beneficent, the Merciful. Master of the Day of Judgement, and Allāh’s Peace and Blessings be upon Muhammad , his family, his noble Companions and all those who follow them.
Masturbation is considered Harām in Islām.
Allāh says in the Qur`ān,
❝And let those who find not the financial means for marriage keep themselves chaste, until Allah enriches them of His bounty.❞
― Al-Qur`ān, Chapter 24, verse 33
This verse clearly states, that whoever does not have the financial means to marry, should keep themselves chaste, and be patient in facing temptations (including masturbation) until Allāh enriches them of His bounty.
From the sunnah of the Prophet :
Abdullāh ibn Mas’ūd said, “We were with the Prophet while we were young and had no wealth whatsoever. So Allāh’s Messenger said,
❝O young people! Whoever among you can marry, should marry, because it helps him lower his gaze and guard his modesty (i.e. his private parts from committing illegal sexual intercourse etc.), and whoever is not able to marry, should fast, as fasting diminishes his sexual power.❞
― Bukharī, 5066
The hadīth orders men, who are not able to marry, to fast despite the hardship encountered in doing so, and not to masturbate despite the ease with which it can be done.
There are additional evidences that can be cited to support that masturbation is harām in Islām. Refer Chapter 23, verses 5-7.
And Allāh knows best.
If I said anything correct, then it is from Allāh, and if I erred, then that is from me and satan.
❝Oh Allāh, I seek refuge in You lest I misguide others, or I am misguided by others, lest I cause others to err or I am caused to err, lest I abuse others or be abused, and lest I behave foolishly or meet with the foolishness of others.❞