The Intention (Niyyah) for Obligatory and Nafl Fasts
The mother of the believers, the wife of Prophet (salallāhu ‘alaihi wasallam), Hafsah bint ‘Umar (radiyallāhu ‘anhumā) stated that Allah’s Messenger (salallāhu ‘alaihi wasallam) said: “Whoever does not commit himself to fasting before Fajr, there is no fast for him.” In another narration he (salallāhu ‘alaihi wasallam) stated: “There is no fast for the one who did not make the intention to fast from the night before.”
These narrations refer to the obligatory fasts, such as the fasting in Ramadan or the fasts that must be made up from Ramadan. The niyyah is the intention to fast and it must be present before the prayer time for Fajr (i.e. before the true dawn). So, if a person intended to fast before Fajr began, and then he fell asleep and did not awake until daytime, then his fast is correct because his niyyah (intention) was present―and he did not eat or drink or nullify his fast in any other way. However, if he fell asleep before Fajr, i.e. in the night, without an intention to fast, and he did not eat or drink after Fajr, and then he thinks to himself, “I will complete my fast and I will not eat or drink,” then his fast is not correct because he began the day without having the intention to fast―and a niyyah cannot be made in retrospect.
So, his fast is not correct. Nevertheless, he must withhold from food and drink for the rest of that day, and he must make up that day after Ramadan.
As for the optional (nafl) fasting, then it is allowed to make the niyyah for it even after Fajr, in the daytime. For example, if one wakes up and he did not eat or drink after Fajr and then he intends to fast (as a nafl), then his fast is correct. This is due to the hadīth of A’ishah (radiyallāhu ‘anhumā) wherein she said, “Allah’s Messenger entered upon me one day and said, ‘Do you have something for me to eat?’ We said, ‘No.’ So, he said, ‘In that case, I am fasting [today].’ Then on another day, he came to us and we said, ‘We have been given a gift of hays (a mixture of dates and ghee).’ He said, ‘Show it to me for I had begun the day fasting.’ And then he ate.”
This hadīth also proves that to break an optional (or nafl) fast is allowed and one is not obligated to complete it. The obligatory fast, however, cannot be broken, and to break it is a major sin.
The intention should be made before each day (i.e. before fajr), and the intention should not be uttered on the tongue by saying, “I intend to fast this day of Ramadān,” rather, the niyyah is the intent to wake up for suhoor (the pre-dawn meal) and, the intent to withhold from food and drink―this is a valid intention. The place of the intention is in the heart. Vocalising the intention and uttering it on the tongue is an innovation (bid’ah) and not from the Sunnah.
 Reported by Ahmad (no. 26457), Abu Dawūd (no. 2454), Ibn Mājah (no. 1700), At-Tirmidhi (no. 730), An-Nasā’ī (4/196), Ibn Khuzaymah (no. 1933) and declared sahīh by Al-Albāni (see Al-Irwā no. 914).
 Ad-Dāruqutni (2/172), see Al-Irwā (no. 914).
 To make up the day, in Arabic: qadā.
 Muslim (no. 1154).
 Al-‘Allāmah Muqbil bin Hādi (rahimahullāh) in Fadā’ih wa Nasā’ih, (p.73-74).