All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
The basic ruling is that a person should protect himself from the sin of masturbation through lawful means such as fasting, increasing Dhikr (remembrance of Allah), and the like. However, if there is no alternative and a person would otherwise fall into committing Zina (fornication), then some scholars have permitted masturbation in such a case of necessity - and this is the view that we adopt on our website due to necessity. Nonetheless, the state of necessity should be dealt with in proportion to its measure, as is well known.
Allah knows best.