Allah has enjoined upon His servants five prayers throughout the day and night at specific times decreed by the wisdom of Allah so that the servant may be in contact with Him in these prayers throughout all of these times.

It is very important to note that if one offers prayer while he is in a state of janabah (impurity), he has to take a bath and repeat the prayers.

Sheikh M. S. Al-Munajjid, a prominent Saudi Muslim lecturer and author states: “According to the consensus of scholars, whoever prays when he is not in a state of Taharah (purification) has to purify himself and repeat the prayer, even if he forgot. An-Nawawi said in Al-Majmu`:

(Muslims unanimously agreed that it is haram to pray when one is impure, and they unanimously agreed that the prayer is not valid whether he knew that he was impure or was unaware of it or forgot. However, if he prayed while not knowing it or having forgotten it, there is no sin on him because he knew that he was impure and that it is haram to pray when one is impure.)

Having a bath following the states of janabah is not valid unless one has the intention of performing ghusl, because the Prophet (peace and blessings be upon him) said: “Actions are but by intentions.” (Reported by al-Bukhari and Muslim) The site of the intention is the heart; it is not required to speak it aloud.

If you remembered that you were in a state of janabah before you took a bath at Maghrib time, and you took a bath for that reason and repeated the prayers that you had offered when you were impure, then that bath is valid because the intention was present. You did well to repeat the prayers because this is what is required of you.

But if you did not remember that you were in a state of janabah until after you had had the bath, and you took a bath in order to clean yourself or to cool yourself down, for example, then this bath did not remove the janabah because there was no intention accompanying it. In that case you have to repeat the bath and the prayers as well. You repeated the bath, so all that remains for you to do is to repeat the prayers. So repeat Fajr, Zuhr, `Asr and Maghrib.