Reference: Fataawa Ramadhaan – Volume 2, Page 443, Fatwa No.369
Question: Last Ramadhaan, while I was fasting, I masturbated. So what am I obliged to do?
Response: You must repent to Allaah from having masturbated because it is prohibited according to the most correct of the two opinions of the people of knowledge. This is based on the saying of Allaah, (Subhaanahu wa Ta’aala):
…and due to the saying of the Prophet ﷺ:
So the Prophet ﷺ directed the youth who could not afford to get married to fast; And no doubt, in fasting there is an element of hardship and if masturbating was permissible, then the Prophet ﷺ would have directed them to it because it is easier upon the youth, in addition to there being a degree of pleasure in it.
And the Prophet ﷺ would not leave something easier for something more difficult if the easier one was permissible. This was his habit that never was he given a choice between two options except that he chose the easier of the two so long as it was not a sin. So his leaving the easier option in this issue shows that it is not permissible.
As for his doing that in Ramadhaan while fasting, then he increases in sin because by doing so, he has broken his fast. So he must repent to Allaah from two things, one from having masturbated and another repentance for having broken his fast. And he is [also] required to make up [the fast] for that day.