From the viewpoint of Sunni, Is Masturbation Haram? What if a person is entangled in a tough situation in which he is surrounded by multiple kinds of sexual attraction and not capable of getting married?
out of sunni imams, 3 of them consider it haram completely, except imam ibn hanbal, who says that it is indeed haram, but except those condition, where it can save you from illegal sexual intercourse. Like in a situation, where you have to masturbate or have sex, then you can choose the lesser of evil (masturbate) to save yourself from major sin of adultery.
more details can be found here: http://islamqa.info/en/329