The evidences indicate that the prostration of forgetfulness is of four types:
1. It is either done because something was added to the prayer
2. Or when something was left out from the prayer
3. Or when one has doubt (as to whether he added to or subtracted from his prayer)
4. Or in the case of taharr (which is when one has doubt then gets it correct).
So if it is done because something was left out from the prayer, then its ruling is found in what has been reported from ‘Abdullaah bin Buhainah (radyAllaahu ‘anhu) that: “The Prophet (sallAllaahu ‘alayhi wa sallam) led them one time in Dhuhr Prayer and then stood up after performing the first two raka’aat and did not sit (for tashahhud) in between. So the people stood up with him and continued until when the prayer was finished and the people were waiting for him to make the tasleem, he (sallAllaahu ‘alayhi wa sallam) said the takbeer while sitting and prostrated twice before making the tasleem. Then he made the tasleem (i.e. saying as-Salaam ‘Alaikum on both sides).”
What was left out of the prayer in this hadeeth was the first tashahhud. As for when something is added to the prayer then its ruling is what has been reported by Abu Hurairah (radyAllaahu ‘anhu) that: “The Prophet (sallAllaahu ‘alayhi wa sallam) prayed one of the two evening prayers (either Maghrib or ‘Ishaa) with two rak’aat then he made the tasleem and then got up to go to a wooden post in the front of the masjid and rested his hand on it. Amongst the crowd was Abu Bakr and ‘Umar but they were afraid to speak to him. The people left the masjid quickly saying: ‘The prayer has been shortened.’ So a man whom the Prophet (sallAllaahu ‘alayhi wa sallam) used to call Dhul-Yadain said: ‘O Messenger of Allaah, did you forget or was the prayer shortened?’ So he said: ‘I did not forget nor was the prayer shortened.’ So he said: ‘Rather you indeed did forget.’ So Allaah’s Messenger (sallAllaahu ‘alayhi wa sallam) prayed two rak’aat and then made the tasleem. Then (while remaining seated) he said the takbeer and prostrated just like before or perhaps longer and then raised his head. Then he said takbeer again and prostrated just like before or perhaps longer and then raised his head saying takbeer…”
So in this hadeeth there was something added to the prayer and it was saying the Salaam after the (first) two raka’aat. This is why Allaah’s Messenger (sallAllaahu ‘alayhi wa sallam) prostrated out of forgetfulness after the Salaam, setting the previous principle as a guideline.
As for when one has doubt, then he must prostrate, as mentioned previously, before saying the Salaam. This is based on the narration of Abu Sa’eed Al-Khudree (radyAllaahu ‘anhu) who reported that Allaah’s Messenger (sallAllaahu ‘alayhi wa sallam) said: “If one of you has doubt in his prayer and he doesn’t know how many (rak’aat) he has prayed – either three or four – then he should cast away the doubt and base it on what he is certain of. Then he should make two prostrations before making the Salaam. So if he prayed five (rak’aat), his prayer will intercede for him. And if he prayed his prayer completely, then in both cases it will serve as a spite against the Devil.” [Reported by Muslim]
In the case of taharr (second consideration), which is when doubt overcomes the person praying, then he realizes the correct status of his prayer and continues, then its ruling is that he perform the prostration of forgetfulness after the Salaam. This is based on what has been reported by Ibn Mas’ood (radyAllaahu ‘anhu) who said: “The Prophet (sallAllaahu ‘alayhi wa sallam) once prayed and when he (finished and) made the tasleem it was said to him: ‘O Messenger of Allaah, something has been introduced into the prayer.’ So he said: ‘And what is it?’ So they said: ‘You prayed in such and such manner.’ So he bent his knees below him and faced the Qiblah. Then he made two prostrations and made the tasleem. Then he turned around and faced the people, saying: ‘If something were to be introduced into the prayer, I would surely inform you of it. However, I am a human being just like you. I forget just as you forget. So if I forget, remind me. And if one of you has doubt in his prayer, and then realizes what is correct, then let him complete it and then prostrate twice.’” [Reported by Al-Bukhaaree and Muslim] In the report of Al-Bukhaaree, it states: “Then let him complete it then prostrate then make the tasleem.” In the report of Muslim: “The Prophet (sallAllaahu ‘alayhi wa sallam) prostrated the two prostrations of forgetfulness after making the tasleem and speaking.”
So we can summarize what has been stated above in the following manner:
If the forgetfulness in one’s prayer causes one to detract something from it, then he must prostrate before making the tasleem based on the hadeeth of ‘Abdullaah bin Buhainah.
And if the forgetfulness causes one to add something to the prayer, whether he makes the tasleem (after two rak’aat) as in the hadeeth of Abu Hurairah (radyAllaahu ‘anhu) or he rises to make a fifth rak’ah during prayer then goes back (to sitting), he must prostrate after the Salaam.
And if he has doubt – he doesn’t know how many raka’aat he has prayed, whether three or four – he must build upon what he is certain of, and this is the lowest (of the choices), and then prostrate before the tasleem.
And if it is the case of taharr (second consideration), which is when one has doubt then becomes certain of what is correct, he must prostrate after saying the Salaam.
And to Allaah belongs the Success, and may the peace and blessings of Allaah be on our Prophet Muhammad and his Companions.