The schools concur that a wilful violation of any wajib act in prayer invalidates it. However mistake (sahw) can be compensated by performing sujud al-sahw as described below.
The Hanafis state: The form of sujud al-sahw is that the musalli should perform two sajdahs followed by the recitation of tashahhud and taslim, prayer and benediction for the Prophet (S). This sujud should be performed after the taslim, provided there is sufficient time (for the salat).
Hence if, for instance, someone makes an involuntary error in al-fajr prayer and finds that the sun has risen before his performing sujud al-sahw, he is not required to perform it any more. The cause necessitating sujud al-sahw is the musalli’s omitting an obligatory part or repeating an essential part (rukn) --such as ruku’ or sujud. If numerous lapses occur (in a single salat), the two sajdahs will suffice for them all, because their repetition is not valid in their opinion. And if there occurs a lapse in the sujud al-sahw it requires no rectification (Majma’ al-’anhur, vol.1, "bab sujud al-sahw").
The Malikis observe: In its form, sujud al-sahw consists of two sajdahs followed by tashahhud without any supplication and benediction for the Prophet (S). As to the place of this sujud, in the event that it is on account of an omission or due to both an omission and an addition, it will be performed before the taslim; but if the cause is only an addition, then after the taslim.
Moreover, sujud al-sahw atones for an involuntary omission of a mustahabb part of salat; hence if the omitted part is a fard (obligatory) part of salat, it cannot be compensated by sujud al-sahw and must be performed.
However, if the mistake is one of involuntary addition -- such as an extra ruku’ or two, or one or two additional rak’ahs -- it is atonable by sujud al-sahw.
The Hanbalis say: It is valid to perform sujud al-sahw before or after the taslim. It consists of two sajdahs followed by tashahhud and taslim. Its causes are involuntary addition or omission as well as doubt. An example of addition is to perform an additional qiyam (standing) or qu’ud (sitting). One who sits where he is supposed to stand or vice versa will perform sujud al-sahw.
Where there is an omission, the following procedure is to be followed in their opinion. If he remembers the omission before starting the qira’ah of the next rak’ah, it is wajib for him to perform the part omitted as well as sujud al-sahw; and if he comes to remember it only after starting the qira’ah of the next rak’ah, the former rak’ah will be annulled and the latter will take its place and sujud al-sahw will also be performed.
To illustrate the same, if a person forgets ruku’ in the first rak’ah and becomes aware of it after performing the sujud (of the same rak’ah), he will perform the ruku’ and then repeat the sujud, and if he becomes aware of it only after starting the qira’ah of the second rak’ah, the former rak’ah will be considered null and void and the second rak’ah will take its place.
An example of doubt necessitating sujud al-sahw is the case when one doubts whether he has performed the ruku’, or has a doubt regarding the number of rak’ahs performed. Here he will consider that portion of the salat he is sure of having performed as the basis and will perform the remaining, and carry out sujud al-sahw on finishing it. Two sajdahs suffice for several mistakes, even if their causes differ, and a lapse committed by someone prone to making mistakes will not be considered a lapse.
According to the Shafi’is, the place of sujud al-sahw is after the tashahhud and benediction of the Prophet (S) and before the taslim. Its mode of performance is like the one prescribed by the above-mentioned schools. The reasons for its performance are: omission of an emphasized (mu’akkadah) sunnah, a little additional recital, the recital of al-Fatihah by mistake, the following of an imam whose salat is vitiated, a doubt in the number of rak’ahs, and the omission of a specific part.
The Imamis differentiate between the rules applicable to cases of doubt and those applicable to errors. They state: No attention will be paid to a doubt arising concerning any act of salat after its completion, or the doubt of a ma’mum regarding the number of rak’ahs if the imam has ascertained their number and vice versa, with each of them referring to the memory of the other.
No significance is attached to the doubts of a person who doubts excessively, and similarly to a doubt with respect to any act of salat arising after entry into its subsequent act. Hence if a doubt occurs regarding the reciting (qira’ah) of al-Fatihah after starting the qira’ah of the subsequent surah, or regarding the surah after having gone into the ruku’, or with respect to the ruku’ after having entered the sajdah, the salat will be continued without heeding the doubt.
But if the doubt occurs before starting the performance of the subsequent act, it is wajib to rectify it. Hence a person who has doubt regarding the recital of al-Fatihah before starting the subsequent surah, will recite it, and similarly the surah if he has a doubt concerning its recital before entering the ruku’.
As to sujud al-sahw, it should be done for every omission and addition, except for reciting aloud instead of in a low voice and vice versa -- as it does not entail anything -- and except for any omission or addition that does not pertain to the essentials (arkan) of salat because their omission or addition invalidates the salat irrespective of its being wilful or by mistake.
The arkan, in their opinion, are the following five: niyyah (intention), takbirat al-ihram, qiyam, ruku’ and the two sajdahs of a rak’ah. It is not obligatory to perform any part omitted by mistake after the salat except sajdah and tashahhud, which are alone required to be performed among the forgotten parts.
These will be performed after the completion of the salat followed by sujud al-sahw, which consists of making two sajdahs and reciting
بسم الله وبالله، اللّهم صلّ على محمد وآل محمد
in the state of prostration, followed by tashahhud and taslim.
The number of sujud al-sahw required is equal to the number of causes entailing it. They consider the mistake of a person committing excessive mistakes and a mistake committed while rectifying one, as no mistake.
The Shafi’is, Malikis and Hanbalis observe: If the musalli has a doubt regarding the number of rak’ahs performed, he will consider the number of rak’ahs he is certain of having performed as the base and will complete the salat by performing the rest.
The Hanafis state: If the musalli’s doubt in salat is for the first time in his life, he will repeat it from the beginning. But if it occurs to him that he has doubted in salat earlier as well, he will think for quite a while and will act in accordance with what seems more probable to him. But if the doubt remains (even after thinking), he will consider the number of rak’ahs he is certain of having performed as the base.
The Imamis state: If the doubt concerning the number of rak’ahs performed occurs in a two-rak’ah salat (such as salat al-subh, the salat of a traveler, salat al-jumu’ah, salat al-’idayn and salat al- kusuf, or in salat al-maghrib or in the first two rak’ahs of ‘isha’, zuhr and ‘asr prayers, the salat will become invalid and it will be wajib to start it again from the beginning. But if the doubt occurs in the rak’ahs subsequent to the first two rak’ahs of the four-rak’ah prayers, he will perform salat al-ihtiyat after completing the salat and before performing any act incompatible with salat.
For example, if a doubt arises after the completion of the two sajdahs of the second rak’ah as to whether it is the second or the third rak’ah, he will take the greater number of rak’ahs as his basis and complete the salat. He will then perform as ihtiyat (caution) a single rak’ah while standing or two rak’ahs while sitting. If the doubt concerns his being in third or fourth rak’ah, he will consider it the fourth rak’ah and complete the salat and follow it up with a single rak’ah standing or two rak’ahs sitting by way of caution.
If the doubt concerns his being in second or fourth rak’ah, he will consider it the fourth rak’ah. He will then offer two rak’ahs standing. If there is a doubt regarding its being second, third or fourth rak’ah, he will assume it to be the fourth rak’ah, and offer following it two rak’ahs standing and two rak’ahs sitting.
According to them, the reason for performing these rak’ahs is to preserve the prescribed form of salat and avoid additions and omissions. Their point is illustrated by the example of a person who has a doubt between its being third or fourth rak’ah. He will consider it to be the fourth rak’ah and perform a single rak’ah separately after completing the salat. If his salat has been complete, the additional rak’ah performed separately will be considered as nafilah, and if the salat had been incomplete, the separate rak’ah will complement it.
However, this manner of performing salat al-ihtiyat (cautionary prayer) is particular to the Imamis. They limit this procedure to the obligatory salats, and among them to zuhr, ‘asr and ‘isha’ prayers only. As to the nafilah prayers, the musalli is free to consider the minimum or maximum rak’ahs probably performed as the basis, provided such supposition does not invalidate the salat (such as where he doubts his being in second or third rak’ah with the knowledge that the nafilah comprises only two rak’ahs; here he will consider the minimum number of rak’ahs probably performed as the basis).
It is better in all mustahabb prayers to consider the minimum ascertainable number of rak’ahs as the basis. If a doubt concerning rak’ahs arises in salat al-ihtiyat, the maximum number of rak’ahs probably performed will be made the basis, except where doing so invalidates the salat, in which case the minimum number of rak’ahs will be the basis. Some Imamis observe: One is free to choose as the basis either the minimum or maximum rak’ahs probably performed.