وخلاصة ما ذهبت إليه في هذه المسألة
إن كان الاستمناء بيد حليلته فجائز بإجماع وقد ذهب إلى هذا المصنف وصرح بالاجماع عليه
إن كان بيد أجنبية أو أدخل الأجنبي أصبعه في فرج إمرأة فحرام إتفاقاً
إن فعله الرجل للتلذذ وإستبدله بالزوجة والأمة فحرام
إن فعله ليكسر حِدّة شهوته وشدة شبقه فحسب فحرام فإن كان هذا الفعل لدفع مضرة الزنى أو اللواط التي باتت أو كادت متحققة في حقه فهو مناح بعد أن يجرب الصيام ويجاهد نفسه ويتقي الله ما إستطاع
بلوغ المنى في حكم الإستمنى للشوكاني
As a summary of what I have addressed regarding this issue:
If masturbation is with the hand of one's wife, it is permissible by universal consensus; relevant to this volume and clear by the universal consensus on it.
If it is with the hand of an unmarriageable relative [ajnabiya], or if an unmarriageable relative inserts his finger in a woman's vagina, it is agreed that this is prohibited.
If a man does it out of pleasure and in place of a wife or a servant girl, it is prohibited.
If he does it to quench the severity of his sex drive and the intensity of his desire, but only this, it is prohibited. If it is done to drive away the detriment of adultery or homosexual activity that is imminent or inevitable with him, then it is permissible, after he tries fasting, wages jihad against himself, and is as devout as he can be to Allah.
Al-Shawkani, Bulugh Al-Muna fi Hukm Al-istimna [The realization of those burdened in the penalty for masturbation]