he gives the salām,” together with the report found in both Ṣaḥīḥ collections from ʿAbd Allāh ibn Buhayna: “The Prophet ﷺ, while still seated, pronounced the takbīr, performed two prostrations before giving the salām, and then gave the salām.”
The Mālikīs maintain that the prostration should be made before the salām when it is prompted by a deficiency, or by a mixture of deficiency and addition, and that it should follow the salām when the cause is addition alone.
Their proof for performing the prostration before the salām in the case of a deficiency is the hadith of Abū Hurayrah reported by al-Bukhārī (1232) and Muslim (389), in which the Prophet ﷺ said, “When any of you stands to pray, Satan comes to him and confuses him until he no longer knows how many rakʿahs he has prayed; let him then, while seated, make two prostrations.”
As for the report dealing with an addition that places the prostration before the salām, it is the hadith of ʿAbd Allāh ibn Buhayna mentioned above.
The Ḥanbalīs agree that the prostration of forgetfulness may be done either before or after the salām; their discussion concerns only which is preferable. If it is required because the worshiper ended the prayer early—having given the salām while still missing a rakʿah or more—the preferred time is after the salām, for it completes the prayer, in light of the hadith of Abū Saʿīd in Muslim and the report of ʿAbd Allāh ibn Buhayna in the two Ṣaḥīḥs. In all other situations, doing it before the salām is preferable. Allah knows best.
Ṣiddīq Ḥasan wrote in Fatḥ al-ʿAllām: “Because the reports on the placement of the prostration of forgetfulness appear to conflict, scholars have differed in how to act upon them. Dāwūd said that each narration is followed in its specific context exactly as it came, without analogy; Aḥmad said the same.”
Others held that the worshiper is free in every case of forgetfulness: if he wishes, he may prostrate after the salām, and if he wishes, before it—whether the lapse involved an addition or a deficiency.
In Subul al-Salām it is stated: “A fair approach recognizes that the hadiths on this matter, both in word and deed, contain an element of apparent contradiction; the sounder view is to regard them as providing latitude, allowing either practice.”