those who err or forget are excused. As He says, relating the supplication of the Messenger and the believers:
“Our Lord, do not hold us accountable if we forget or make a mistake.”
It is established in the authentic collection, in a hadith narrated by Abū Hurayrah, that Allah answered this supplication. Moreover, the scriptural evidence indicates that speaking and similar acts that invalidate prayer are excused when done forgetfully or in ignorance. This is the position of Mālik, al-Shāfiʿī, and Ahmad according to one of the two reports from him.
This is supported by the hadith of Dhū al-Yadayn and similar reports; the hadith of Muʿāwiyah ibn al-Hakam al-Sulamī, who invoked Allah’s mercy upon someone who sneezed during prayer; and the hadith of Ibn Masʿūd concerning the tashahhud, recorded by both al-Bukhārī and Muslim. They initially used to say, “Peace be upon Allah before His servants.” He forbade them to say this, declaring, “Allah Himself is al-Salām (the Source of Peace),” and instructed them to recite the familiar tashahhud, without ordering them to repeat their prayers. The same applies to the hadith of the Bedouin who said in his supplication, “O Allah, have mercy on me and on Muhammad, and do not have mercy on anyone else along with us,” and other such reports. These and similar accounts show that prohibited acts, whether in prayer or otherwise, are excused when committed through forgetfulness, error, or comparable circumstances.
Accordingly, if a person is unaware of the impurity, his prayer is valid both inwardly and outwardly. He therefore has no need to inquire about matters which, if disclosed to him, would distress him, and which Allah has overlooked. Some of these people may reach the point of disliking prayer