It goes without saying that the obligatory fast is the one in Ramadan, but perpetual fasting all through Rajab and Sha`ban and joining them with Ramadan is not recommended by some scholars. However, offering fast for some days in Rajab and Sha`ban is recommended, and earns a great reward.
Highlighting this concept, the prominent Muslim scholar Sheikh `Atiyyah Saqr, former Head of Al-Azhar Fatwa Committee, issues the following fatwa:
Fasting in Ramadan is obligatory as well as offering fast for fulfilling a vow, or as an expiation. As for other types of fasting, they are merely recommended. The Messenger of Allah (peace and blessings be upon him) encouraged people to offer voluntary fast in a hadith reported in the two sahihs (Authentic Collections) of both Al-Bukhari and Muslim. The hadith reads: “Indeed, anyone who fasts for one day for Allah’s Pleasure, Allah will keep his face away from the (Hell) fire for (a distance covered by a journey of) seventy years.”
Furthermore, the commendable fast is in the sacred months, of which Rajab is one, as well as in Sha`ban.
However, Ibn Hajar related that it is reprehensible to fast in Rajab carrying the intention of making it similar to Ramadan or thinking that it has a special merit pertaining to the month itself.
There are authentic hadith about the virtues of fasting in Sha`ban. Al-Bukhari reported that `A’ishah (may Allah be pleased with her) said that the Prophet (peace and blessings be upon him) used to observe the most fast in Sha`ban; it seemed even that the Prophet fasted throughout that month. In a narration about this, it is reported that the Prophet did that to celebrate the approaching of month of Ramadan. An-Nasa’i reported that Usama ibn Zayd (may Allah be pleased with him) asked the Prophet (peace and blessings be upon him), “I have never seen you offer fast in a month as you do in Sha`ban.” The Prophet said, “It is a month people disregard that is between Rajab and Ramadan. In that month deeds are presented to the Lord of the Worlds, so I like my deeds to be presented while I am fasting.”
As for fasting perpetually or fasting in the end of Sha`ban and connecting it with Ramadan, it is not recommended to fast during that period, for in a Prophetic hadith reported by Abu Dawud, which Ash-Shafi`i based his opinion on, it is forbidden to fast in the two days before Ramadan. The group of narrators related a hadith that goes: Allah’s Messenger (peace and blessings be upon him) said: “None of you should fast a day or two before the month of Ramadan unless he has the habit of observing voluntary fasting (and if his fasting coincides with that day), then he can fast that day.”
There are no hadiths that render fasting Rajab and Sha`ban perpetually and linking them to Ramadan as a dispraised innovation in religion. As I said earlier, fasting in Rajab and Sha`ban is permissible. As for Rajab, it’s is one of the sacred months. Regarding Sha`ban, the Prophet (peace and blessings be upon him) used to fast in it. Nevertheless, there is advice for Muslims not to overburden themselves by fasting more than they can bear. In a hadith reported by Al-Bukhari and Muslim, `A’ishah (may Allah be pleased with her) narrated: The Prophet never fasted in any month more than in the month of Sha`ban. He used to say: “Do those deeds which you can do easily, as Allah will not get tired (of giving rewards) till you get bored and tired (of performing righteous deeds).”
Moreover, if one continues fasting the two months consecutively although this might affect fasting in Ramadan, then one will be heedless to the above mentioned hadith. The same applies even if it was for fasting because of a vow because this will overburden one. However, fasting in Rajab and Sha`ban is allowed for the one who is able to fast without getting tired. Furthermore, if a wife wants to observe a voluntary fast, she shall take her husband’s permission. This is according to the hadith reported by Al-Bukhari and Muslim: “A woman should not fast (optional fasts) except with her husband’s permission if he is at home (staying with her).”