Praise be to Allah.
The fuqaha’ differed concerning this matter and there are two views, based on their difference of opinion about making an intention specific. The issue is, does he have to intend to fast specifically for Ramadaan, or is it sufficient for him to have the intention of fasting, whether he intends it as an obligatory or naafil fast?
The majority of Maalikis, Shaafa’is and Hanbalis are of the view that he has to stipulate that he intends to fast for Ramadaan.
The Hanafis are of the view that he does not have to have a specific intention. This was also narrated from Ahmad.
Based on this view, the fast of one who says “If tomorrow is Ramadaan then this is my obligatory fast” is valid.
It says in al-Furoo’ (3/40): It is essential to form a specific intention for each obligatory fast, according to Maalik and al-Shaafa’i. This means that he should form the intention of fasting Ramadaan or making up a missed fast or fasting in fulfilment of a vow or as an expiation, because the Prophet (peace and blessings of Allaah be upon him) said: “Each person will have but that which he intended.”
Another view was also narrated from Imam Ahmad, which is that he does not have to form a specific intention for Ramadaan, which is similar to the view of Abu Haneefah, because specifying is for the purpose of distinguishing and the time of Ramadaan is already distinct from other times, therefore the general intention of fasting is valid. If someone wants to form the intention of observing an obligatory fast but he was not certain …
When he said “If someone wants to form the intention of observing an obligatory fast but he was not certain”, such as if he formed his intention on the night of doubt by saying: “If tomorrow is Ramadaan then my fast will be obligatory and if it is not then it will be naafil,” this is not valid, according to the first view, until he is certain that he will fast tomorrow for Ramadaan. But according to the second view it is valid. End quote.
It says in al-Insaaf (3/295): If his intention is “If tomorrow is Ramadaan it will be my obligatory fast otherwise it will be a naafil fast,” this is not valid. This is our view and it is the view of the majority of our companions. This is based on the fact that it is essential to form a specific opinion. It was narrated from Imam Ahmad that this is valid, and this is based on a report that says it is not essential to form a specific intention in the case of Ramadaan. This view was favoured by Shaykh al-Islam Taqiy al-Deen. It says in al-Faa’iq: This was supported by the author of al-Muharrar and by our Shaykh, and it is the favoured view. End quote.
See: al-Bahr al-Raa’iq, 2/280; Majma’ al-Anhaar, 1/233; Mughni al-Muhtaaj, 2/150; al-Mughni, 3/9; al-Mawsoo’ah al-Fiqhiyyah, 5/165, 28/22.
Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) said, commenting on the view of the author of al-Zaad: If his intention is, ‘If tomorrow is Ramadaan then it is my obligatory fast’, that is not valid.
This issue is important and comes up frequently. For example: a man slept early on the night before the thirtieth of Sha’baan, and it is possible that this night may be the first of Ramadaan, so he said: ‘If tomorrow is Ramadaan then it will be my obligatory fast,’ or he said, ‘If tomorrow is Ramadaan then I am fasting,’ or, ‘If tomorrow is Ramadaan then it is my obligatory fast, and if it is not then it is an obligatory expiation’ and the like. Our view is that this is not valid, because his words, ‘If it is Ramadaan then it is my obligatory fast’ show a kind of uncertainty, but intentions must be based on certainty. So if he does not wake up until after dawn and he finds out that it is Ramadaan, then he has to make up this day, according to the author.
The second view narrated from Imam Ahmad is that his fast is valid if he finds out that it is Ramadaan. This view was favoured by Shaykh al-Islam Ibn Taymiyah (may Allaah have mercy on him). Perhaps this is included in the general meaning of the words of the Prophet (peace and blessings of Allaah be upon him) to Dubaa’ah bint al-Zubayr: “Go for Hajj, and stipulate that if you are prevented from continuing, you will exit ihraam at that point and Allaah will accept whatever you stipulate.” This man made his intention conditional because he did not know whether the next day would be Ramadaan, so his hesitation was based on uncertainty about the month, but there was no uncertainty about whether he would fast or not. Hence if he said on the night before the first of Ramadaan: ‘I may fast tomorrow or I may not,’ we say that this is not valid because it is uncertainty. … Based on this, if we go to sleep on the night before the thirtieth of Sha’baan , we may intend that if the next day is Ramadaan, we will fast.
End quote from al-Sharh al-Mumti’, 6/375.
And Allaah knows best.