If a woman’s nifaas ends before forty days, she should do ghusl and pray and fast
The majority of scholars, including the four imams, are of the view that there is no minimum limit for nifaas. Whenever a woman becomes pure from nifaas, she has to do ghusl and pray and fast, even if that is before forty days have passed since the birth. Because no precise definition has been narrated in sharee’ah with regard to the minimum length of nifaas, so the matter should be based on experience, which shows that nifaas may be very short or it may be long. - Ibn Qudaamah in al-Mughni, 1/428. Some of the scholars narrated that there was consensus on this point. Al-Tirmidhi (may Allaah have mercy on him) said: The scholars among the companions of the Prophet (peace and blessings of Allaah be upon him), the Taabi’een and those who came after them are agreed that a woman in nifaas should stop praying for forty days, unless she sees that she has become pure before that, in which case she should do ghusl and pray.
See al-Majmoo’ by al-Nawawi, 2/541.
Shaykh Ibn Baaz (15/195) was asked: is it permissible for a woman in nifaas to pray, fast and do Hajj before forty days if she becomes pure (i.e., if the bleeding stops)?
He replied: yes it is permissible for her to fast, pray and do Hajj and ‘umrah, and it is permissible for her husband to have intercourse with her within forty days, if she becomes pure. If she becomes pure after twenty days, she should do ghusl and pray and fast, and she is permissible for her husband. The report from ‘Uthmaan ibn Abi’l-Aas which says that he regarded that as makrooh is to be understood as meaning disliked but not forbidden; this is his ijtihaad, but there is no evidence for that.
The correct view is that there is nothing wrong with that if the woman becomes pure before forty days. If the bleeding resumes within forty days, then the correct view is that she should regard it as nifaas within the forty-day period, but her fasts, prayers and Hajj at the time when she was pure are still valid and she does not have to repeat any of them, so long as they were done when she was pure.
It says in Fataawa al-Lajnah al-Daa’imah (5/458):
If a woman in nifaas sees that she has become pure before forty days are over, then she should do ghusl and pray and fast, and her husband may have intercourse with her.
The Standing Committee (10/155) was asked about a woman who gave birth seven days before Ramadaan, then she became pure and fasted Ramadaan. They replied: If the matter is as described and she fasted Ramadaan at a time when she was pure, then her fast is valid and she does not have to make it up.
Don't miss out to watch Islamhelpline sponsored Islamic Kids Competition