Praise be to Allaah.
If a menstruating woman becomes pure before Fajr then she should have the intention of fasting and her fast is valid, even if she does not do ghusl until after dawn comes.
The same ruling applies to one who is junub (in a state of impurity following sexual activity) if he does not do ghusl until after dawn comes.
Al-Bukhaari (1962) and Muslim (1109) narrated from Sulaymaan ibn Yasaar that he asked Umm Salamah (may Allaah be pleased with her (about a man who wakes up junub – can he fast? She said: The Messenger of Allaah (peace and blessings of Allaah be upon him) used to wake up junub not from a wet-dream and he would fast.
Al-Nawawi (may Allaah have mercy on him) said:
The scholars of these cities are unanimously agreed that the fast of one who is junub is valid, whether that was as the result of a wet dream or of intercourse.
If the blood of menstruation or nifaas (post-partum bleeding) stops at night, then dawn comes before the woman does ghusl, her fast is valid and she has to complete it, whether she did not do ghusl deliberately or because she forgot, with or without an excuse. The same applies to one who is junub. This is our view and the view of all the scholars, apart from that which was narrated from some of the salaf but we do not know whether it is saheeh or not.
And Allaah knows best.