I swore to fast one month successively if I were to masturbate, given that I swore to do so in order to oblige myself to give up masturbation. However, Satan, may Allah protect us from him, lured me into masturbation again. What is the ruling in this case? Should I fast (as expiation)?
All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His Slave and Messenger.
If the statement by which the questioner intended to prevent himself from committing that sin was, "By Allaah (or something to this effect), if I do such-and-such act again, then I will fast one month consecutively," then it is a statement that suggests swearing a valid, binding oath. It is incumbent on him to fulfill his oath and fast one month successively if he breaks his oath. If he does not fast, then he should offer expiation for breaking his oath.
However, if the questioner did not swear by Allaah, the Exalted, but merely verbally committed himself to fast one month if he masturbated again with the purpose of preventing himself from committing that sin, then it is considered a vow of lajaj (a vow of anger). It is a vow that one makes in order to prevent himself from doing something. The ruling in this case is that if the condition upon which the person renders his vow conditional is fulfilled—in this context, again, it is masturbating—then the person has the choice either to deliver on his vow and fast one month successively or offer expiation like for breaking an oath. Despite the fact that scholars held different opinions in this regard, the one which we have mentioned here is the correct opinion in our view. This is the well-known opinion of Imam Ahmad's school of Fiqh. We would like to point out to the questioner that the optimal means to prevent oneself from committing sins and curb unlawful desires is to be mindful of Allaah, the Exalted, and always remind oneself that He is the Knower of what is hidden and what is open. Moreover, one should remind himself that there are angels who are assigned to record all his deeds. They do not leave a small or a big thing without recording it.
Furthermore, the best means to protect oneself from the evil of masturbation is to get married or resort to fasting for this was the advice of the Prophet, sallallaahu ‘alayhi wa sallam, as he said: "O young men, those among you who can afford marriage should marry for it restrains eyes (from casting evil and lustful glances) and preserves one from immorality (and guarding chastity); but he who cannot afford it should fast for it is a means of controlling sexual desire (i.e. diminishes sexual power)." [Al-Bukhari and Muslim; the wording is that of Muslim]
Allaah Knows best.
You can search for fatwa through many choices