Is the intention (Niyyah) a prerequisite for the validity of any fast, obligatory or voluntary?
General Chapter
Al-Mughni
Book of Fasting
Primary text
Intention is a prerequisite for the validity of any fast, whether obligatory or voluntary, by consensus, as fasting is a pure act of worship requiring intention, similar to prayer. For obligatory fasts, such as performing or making up Ramadan fasts, vows, or expiations, the intention must be formed during the night preceding the dawn according to my Madhhab, Malik, and Al-Shafi'i. This is supported by the hadith narrated via Hafsah: "Whoever does not form the intention to fast from the night, then he has no fast." Since it is an obligatory fast, it requires the intention to be present at night, similar to making up a missed fast.
Supporting text
Abu Hanifa permits fasting for Ramadan and any designated fast with an intention formed during the daytime. His evidence is the Prophet's command on Ashura morning: "Whoever woke up fasting, let him complete his fast, and whoever woke up having eaten, let him fast the remainder of his day, and whoever did not eat, let him fast." This was an obligatory fast, and since its obligation did not become fixed in the soul beforehand, intention during the day suffices, like a voluntary fast.