حَدَّثَنَا أَبُو إِسْحَاقَ إِسْمَاعِيلُ بْنُ يُونُسَ بْنِ يَاسِينَ ، ثنا إِسْحَاقُ بْنُ أَبِي إِسْرَائِيلَ ، ثنا عَبْدُ اللَّهِ بْنُ جَعْفَرٍ ، عَنْ زَيْدِ بْنِ أَسْلَمَ ، عَنْ عَطَاءِ بْنِ يَسَارٍ ، عَنِ ابْنِ عَبَّاسٍ ، قَالَ : قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ : " إِذَا شَكَّ أَحَدُكُمْ فِي صَلاتِهِ فَإِنِ اسْتَيْقَنَ أَنَّهُ قَدْ صَلَّى ثَلاثًا فَلْيُصَلِّ وَاحِدَةً بِرَكْعَتِهَا وَسَجْدَتَيْهَا ، ثُمَّ لِيَتَشَهَّدْ فَإِذَا فَرَغَ فَلَمْ يَبْقَ إِلا أَنْ يُسَلِّمَ فَلْيَسْجُدْ سَجْدَتَيْنِ وَهُوَ جَالِسٌ ثُمَّ يُسَلِّمُ ، فَإِنْ كَانَ صَلَّى ثَلاثًا وَكَانَتِ الرَّكْعَةُ الَّتِي صَلَّى رَابِعَةً كَانَتِ السَّجْدَتَانِ تَرْغِيمًا لِلشَّيْطَانِ ، وَإِنْ كَانَ صَلَّى أَرْبَعًا وَكَانَتِ الرَّكْعَةُ الَّتِي صَلَّى خَامِسَةً شَفَعَهَا بِسَجْدَتَيْنِ " .
Sayyiduna Abdullah bin Abbas (may Allah be pleased with them both) narrates: The Noble Prophet (peace and blessings be upon him) said: "When a person has doubt about his prayer, if he is certain that he has performed three rak‘ahs, then he should perform one more rak‘ah and do two prostrations (of forgetfulness), then sit for tashahhud, and when he has finished and nothing remains to be recited except the salam, at that time he should perform two prostrations of forgetfulness, then he should say the salam. If he had performed three rak‘ahs, then the rak‘ah he has now performed will be the fourth, and the two prostrations of forgetfulness will rub the nose of Satan in the dust. And if he had already performed four rak‘ahs, then the one he has now performed will be the fifth, and these two prostrations will make this fifth rak‘ah even."