Taken from: Fatawa Arkan al-Islam
Question:
What is the ruling regarding a person who performs Salah without having taken the obligatory ghusl?
If a person has already prayed and later realizes that he was in a state requiring ghusl, what should he do?
Answer:
Al-ḥamdu lillāh, waṣ-ṣalātu wa-s-salāmu ʿalā Rasūlillāh, ammā baʿd!
If someone has performed Salah and afterwards comes to know that he was in a state of janābah (major ritual impurity) or any other condition requiring ghusl, then it is obligatory upon him to:
❀ Perform ghusl immediately to attain ritual purity.
❀ Repeat all the prayers he performed in that state.
Evidence:
The Messenger of Allah ﷺ said:
“لَا یَقْبَلُ اللّٰہُ صَلَاةً بِغَیْرِ طُہُورٍ“
(Ṣaḥīḥ Muslim, Kitāb aṭ-Ṭahārah, ḥadīth: 224; Sunan an-Nasā’ī, Kitāb aṭ-Ṭahārah, ḥadīth: 139)
Translation:
“Allah does not accept any prayer without purification.”
Ruling:
Any Salah performed without the required ghusl is invalid until ghusl is performed and the Salah is repeated.
ھذا ما عندي والله أعلم بالصواب