Sujud as-Sahw (the prostration of forgetfulness) is prescribed to make up for the shortcomings and mistakes occurring in both fard (obligatory) prayers and nafl (supererogatory) prayers when there is a reason for it.
The prostration of forgetfulness in prayer is generally prescribed for three (3) reasons:
1- Doing something extra, such as making an extra bow (ruku`), prostration (sujud), standing or sitting
2- Neglecting something, such as omitting an essential part (rukn) of the prayer, or omitting one of the obligatory parts of the prayer.
3- Being uncertain, such as when a person is not sure how many rak’ahs he has prayed, whether it was three or four or how many sajdahs he made one or two.
In the case of doing something extra, if a person deliberately adds something to his prayer – bowing, prostrating, standing or sitting, then his prayer becomes invalid, because when he added it, he did that contrary to the manner ordained by Allah and His Messenger (peace and blessings be upon him). The Prophet (peace and blessings be upon him) said: “Whoever does an action that is not part of this matter of ours (i.e., Islam), will have it rejected.” (Muslim).
But if he did that extra thing by mistake, then his prayer is not invalid, but he should do the prostration of forgetfulness after saying the salam. The evidence for that is the hadith of Ibn Mas’ud who narrated that the Prophet (peace and blessings be upon him) led them in praying Zuhr and he prayed five rak’ahs.
When he had finished it was said to him: “Has something been added to the prayer?” He said: “Why are you asking that?” They said: “You prayed five (rak’ahs).” So he turned towards the qiblah and prostrated twice. ( al-Bukhaari, Muslim).
In the case of omitting something, if a person omits one of the essential parts of the prayer, one of the following two scenarios must apply:
Either he remembers it before he reaches the same point in the following rak’ah, so he has to go back and do that essential part of the prayer and whatever came after it.
Or he does not remember it until he reaches the same point in the following rak’ah, in which case the following rak’ah takes the place of the one in which he omitted that essential part, and he should make up the invalid rak’ah.
In either of these two cases, he should do the prostration of forgetfulness after saying the salam.
Omitting an obligatory part of the prayer – such as if he omits an obligatory part and moves on to the next part of the prayer. For example, he forgets to say Subhan Rabbiy al-A’la (Glory be to my Lord Most High) and he does not remember until he has got up from prostrating. In this case he has omitted an obligatory part of the prayer by mistake, so he should carry on with his prayer then do the prostration of forgetfulness before saying the salaam, because when the Prophet (peace and blessings be upon him) omitted the first tashahhud he carried on with his prayer and did not go back and repeat anything, then he did the prostration of forgetfulness before saying the salam.
In the case of being uncertain, such as if a person is not sure if he has done something extra or omitted something, e.g., he is not sure whether he has prayed three rak’ahs or four, one of the following two scenarios must apply:
Either he thinks that one or the other is more likely to be case, whether it is doing more or omitting something, in which case he should proceed on the basis of what he thinks is more likely to be the case, complete his prayer accordingly, then do the prostration of forgetfulness after saying the salam;
Or nothing appears more likely to be the case, so he should proceed on the basis of what is certain, namely the lesser amount, and complete his prayer accordingly, then do the prostration of forgetfulness before saying the salam.
For example: a man prays Zuhr then he is not sure whether he is praying the third or fourth rak’ah, but he thinks it more likely that it is the third. So he should pray another rak’ah, then say the salam, then do the prostration of forgetfulness.
An example of when nothing seems to him more likely to be the case is when a man is praying Zuhr and is not sure whether he is in the third rak’ah or the fourth, and neither seems to him more likely to be the case. In that case he should proceed on the basis of what is certain, which is the lesser amount. So he should regard it as the third rak’ah, then do another rak’ah and do the prostration of forgetfulness before saying the salam.
How to Offer Sujud as-Sahw