160569: Does thinking that leads to ejaculation invalidate the fast?

In a European country during Ramadan, I experienced strong sexual provocation by means of thinking, which led to the emission of maniy. Because I believed that my fast had been invalidated, I went ahead and masturbated. Do I have to make up the fast or offer any expiation?.

Praise be to Allaah.

The Muslim has to guard his hearing, his vision and all his
faculties against doing that which Allah, may He be exalted, has forbidden
to him. The basic principle is that fasting purifies the soul and is a
shield that protects a person from falling into whims and desires.

The scholars differed as to whether the fast is invalidated
by emitting maniy as a result of thinking. The Maalikis said that it does
invalidate the fast, but the majority of scholars did not regard it as
invalidating the fast. It seems that they did not regard it as invalidating
the fast because the individual has no control over it; it is something that
crossed his mind that he could not ward off. But in the case of deliberately
thinking and giving one’s imagination free rein with the aim of ejaculating,
there is no difference – in that case – between that and deliberately
looking at something for the purpose of ejaculating. The majority are of the
view that the fast is invalidated by deliberately looking until one
ejaculates.

It says in al-Mawsoo‘ah al-Fiqhiyyah, 26/267:

The Hanafis and Shaafa‘is are of the view that emission of
maniy or madhiy as a result of looking or thinking does not invalidate the
fast. But the more correct view according to the Shaafa‘is is that if one
habitually ejaculates by looking, or one looks repeatedly and then
ejaculates, that invalidates the fast.

The Maalikis and Hanbalis are of the view that the emission
of maniy as a result of persistent looking invalidates the fast, because it
is emitted as a result of an action that is enjoyed and that one could have
put a stop to.

With regard to ejaculation as a result of thinking, it
invalidates the fast according to the Maalikis, but according to the
Hanbalis it does not invalidate it because it was difficult to avoid it. End
quote.