In light of the Holy Quran and the Hadith, the Fuqaha (jurists) have declared masturbation as prohibited and punishable offence. A major reason for this is that semen is wasted through this. Although even in coitus interruptus semen is wasted, but in some special situations, it has been ruled to be permissible with a degree of undesirability and in some other cases, it is permissible without any undesirability at all.
As given in Fatawa A’alamgiri, Vol. 2, Pg. No. 412.