Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
suyuti:2041a

when one of you is in doubt about his prayer (i.e, how much he has prayed), he should throw away his doubt and base his prayer on what he is sure of. When he is sure about the completion of his prayer, he should make two prostrations (at the end of the prayer). If the prayer is complete, the additional rak’ah and the two prostrations will be supererogatory prayer. If the prayer is incomplete, the additional rak’ahs will compensate it, and the two prostrations will be a disgrace for the devil. (Using translation from Abū Dāʾūd 1024)   

السيوطي:٢٠٤١a

"إِذَا شكّ أحدُكُمْ في صَلاتِه فْليُلقِ الشَّكَ، وليَبْنِ على اليقينِ، فإِن استيقَنَ التمام سجدَ سجْدتين، فإِنْ كانتْ صلاتُه تامة كانتْ الركْعةُ نافلة والسجْدتان نافلةً، وإنْ كانت ناقصةً كانتْ الركعةُ تمامَ الصَلاةِ، والسجْدتان تُرْغمان أنْفَ الشَّيطان".  

[حب] ابن حبّان [ك] الحاكم في المستدرك عن أبي سعيد

See similar narrations below:

Collected by Abū Dāwūd, Ibn Mājah, Ḥākim, Ibn Ḥibbān, Nasāʾī's Kubrá, Bayhaqī
abudawud:1024Muḥammad b. al-ʿAlāʾ > Abū Khālid > Ibn ʿAjlān > Zayd b. Aslam > ʿAṭāʾ b. Yasār > Abū Saʿīd al-Khudrī

when one of you is in doubt about his prayer (i.e, how much he has prayed), he should throw away his doubt and base his prayer on what he is sure of. When he is sure about the completion of his prayer, he should make two prostrations (at the end of the prayer). If the prayer is complete, the additional rak’ah and the two prostrations will be supererogatory prayer. If the prayer is incomplete, the additional rak’ahs will compensate it, and the two prostrations will be a disgrace for the devil.  

أبو داود:١٠٢٤حَدَّثَنَا مُحَمَّدُ بْنُ الْعَلاَءِ حَدَّثَنَا أَبُو خَالِدٍ عَنِ ابْنِ عَجْلاَنَ عَنْ زَيْدِ بْنِ أَسْلَمَ عَنْ عَطَاءِ بْنِ يَسَارٍ عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ قَالَ

قَالَ رَسُولُ اللَّهِ ﷺ إِذَا شَكَّ أَحَدُكُمْ فِي صَلاَتِهِ فَلْيُلْقِ الشَّكَّ وَلْيَبْنِ عَلَى الْيَقِينِ فَإِذَا اسْتَيْقَنَ التَّمَامَ سَجَدَ سَجْدَتَيْنِ فَإِنْ كَانَتْ صَلاَتُهُ تَامَّةً كَانَتِ الرَّكْعَةُ نَافِلَةً وَالسَّجْدَتَانِ وَإِنْ كَانَتْ نَاقِصَةً كَانَتِ الرَّكْعَةُ تَمَامًا لِصَلاَتِهِ وَكَانَتِ السَّجْدَتَانِ مُرْغِمَتَىِ الشَّيْطَانِ  

قَالَ أَبُو دَاوُدَ رَوَاهُ هِشَامُ بْنُ سَعْدٍ وَمُحَمَّدُ بْنُ مُطَرِّفٍ عَنْ زَيْدٍ عَنْ عَطَاءِ بْنِ يَسَارٍ عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ عَنِ النَّبِيِّ ﷺ وَحَدِيثُ أَبِي خَالِدٍ أَشْبَعُ
abudawud:1026al-Qaʿnabī > Mālik > Zayd b. Aslam > ʿAṭāʾ b. Yasār

The Prophet ﷺ said: When one of you is in doubt about his prayer, and does not know how much he has prayed, three or four rak'ahs, he should pray one (additional) rak'ah and make two prostrations while sitting before giving the salutation. If the (additional) rak'ah which he prayed is the fifth one, he will make it an even number by these two prostrations. If it is the fourth one, the two prostrations will be a disgrace for the devil.  

أبو داود:١٠٢٦حَدَّثَنَا الْقَعْنَبِيُّ عَنْ مَالِكٍ عَنْ زَيْدِ بْنِ أَسْلَمَ عَنْ عَطَاءِ بْنِ يَسَارٍ

أَنَّ رَسُولَ اللَّهِ ﷺ قَالَ إِذَا شَكَّ أَحَدُكُمْ فِي صَلاَتِهِ فَلاَ يَدْرِي كَمْ صَلَّى ثَلاَثًا أَوْ أَرْبَعًا فَلْيُصَلِّ رَكْعَةً وَيَسْجُدْ سَجْدَتَيْنِ وَهُوَ جَالِسٌ قَبْلَ التَّسْلِيمِ فَإِنْ كَانَتِ الرَّكْعَةُ الَّتِي صَلَّى خَامِسَةً شَفَعَهَا بِهَاتَيْنِ وَإِنْ كَانَتْ رَابِعَةً فَالسَّجْدَتَانِ تَرْغِيمٌ لِلشَّيْطَانِ  

ibnmajah:1210Abū Kurayb > Abū Khālid al-Aḥmar > Ibn ʿAjlān > Zayd b. Aslam > ʿAṭāʾ b. Yasār > Abū Saʿīd al-Khudrī

“The Messenger of Allah ﷺ said: ‘If anyone of you is uncertain about his prayer, let him put aside uncertainty and act upon that which is certain. When he has made sure his prayer is complete, then let him prostrate twice. Then if his prayer was complete, that (extra) Rak’ah will be counted as voluntary, and if his prayer was lacking, that Rak’ah will complete his prayer, and the two prostrations will rub the Satan’s nose in the dust.’”  

ابن ماجة:١٢١٠حَدَّثَنَا أَبُو كُرَيْبٍ حَدَّثَنَا أَبُو خَالِدٍ الأَحْمَرُ عَنِ ابْنِ عَجْلاَنَ عَنْ زَيْدِ بْنِ أَسْلَمَ عَنْ عَطَاءِ بْنِ يَسَارٍ عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ قَالَ

قَالَ رَسُولُ اللَّهِ ﷺ إِذَا شَكَّ أَحَدُكُمْ فِي صَلاَتِهِ فَلْيُلْغِ الشَّكَّ وَلْيَبْنِ عَلَى الْيَقِينِ فَإِذَا اسْتَيْقَنَ التَّمَامَ سَجَدَ سَجْدَتَيْنِ فَإِنْ كَانَتْ صَلاَتُهُ تَامَّةً كَانَتِ الرَّكْعَةُ نَافِلَةً وَإِنْ كَانَتْ نَاقِصَةً كَانَتِ الرَّكْعَةُ لِتَمَامِ صَلاَتِهِ وَكَانَتِ السَّجْدَتَانِ رَغْمَ أَنْفِ الشَّيْطَانِ  

hakim:1202al-Ḥākim

“The Messenger of Allah ﷺ said: ‘If anyone of you is uncertain about his prayer, let him put aside uncertainty and act upon that which is certain. When he has made sure his prayer is complete, then let him prostrate twice. Then if his prayer was complete, that (extra) Rak’ah will be counted as voluntary, and if his prayer was lacking, that Rak’ah will complete his prayer, and the two prostrations will rub the Satan’s nose in the dust.’” (Using translation from Ibn Mājah 1210)   

الحاكم:١٢٠٢حَدَّثَنَا الْحَاكِمُ أَبُو عَبْدِ اللَّهِ مُحَمَّدُ بْنُ عَبْدِ اللَّهِ الْحَافِظُ إِمْلَاءً فِي رَجَبٍ سَنَةَ خَمْسٍ وَتِسْعِينَ وَثَلَاثِ مِائَةٍ أَخْبَرَنِي مُحَمَّدُ بْنُ الْقَاسِمِ بْنِ عَبْدِ الرَّحْمَنِ الْعَتَكِيُّ ثنا إِسْمَاعِيلُ بْنُ قُتَيْبَةَ السُّلَمِيُّ وَأَحْمَدُ بْنُ مُحَمَّدِ بْنِ سِيرِينَ الْجُرْجَانِيُّ قَالَا ثنا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ ثنا أَبُو خَالِدٍ الْأَحْمَرُ عَنِ ابْنِ عَجْلَانَ عَنْ زَيْدِ بْنِ أَسْلَمَ عَنْ عَطَاءِ بْنِ يَسَارٍ عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ قَالَ

قَالَ رَسُولُ اللَّهِ ﷺ «إِذَا شَكَّ أَحَدُكُمْ فِي صَلَاتِهِ فَلْيُلْقِ الشَّكَّ وَلْيَبْنِ عَلَى الْيَقِينِ فَإِنِ اسْتَيْقَنَ التَّمَامَ سَجَدَ سَجْدَتَيْنِ فَإِنْ كَانَتْ صَلَاتُهُ تَامَّةً كَانَتِ الرَّكْعَةُ نَافِلَةً وَالسَّجْدَتَانِ وَإِنْ كَانَتْ نَاقِصَةً كَانَتِ الرَّكْعَةُ تَمَامًا لِصَلَاتِهِ وَالسَّجْدَتَانِ يُرْغِمَانِ أَنْفَ الشَّيْطَانِ»  

هَذَا حَدِيثٌ صَحِيحٌ عَلَى شَرْطِ مُسْلِمٍ وَلَمْ يُخَرِّجَاهُ بِهَذِهِ السِّيَاقَةِ

ذِكْرُ خَبَرٍ ثَانٍ يُصَرِّحُ بِصِحَّةِ مَا ذَكَرْنَاهُ

ibnhibban:2664al-Ḥusayn b. Muḥammad b. Muṣʿab > Abū Saʿīd al-Ashaj > Abū Khālid al-Aḥmar > Ibn ʿAjlān > Zayd b. Aslam > ʿAṭāʾ b. Yasār > Abū Saʿīd al-Khudrī

“The Messenger of Allah ﷺ said: ‘If anyone of you is uncertain about his prayer, let him put aside uncertainty and act upon that which is certain. When he has made sure his prayer is complete, then let him prostrate twice. Then if his prayer was complete, that (extra) Rak’ah will be counted as voluntary, and if his prayer was lacking, that Rak’ah will complete his prayer, and the two prostrations will rub the Satan’s nose in the dust.’” (Using translation from Ibn Mājah 1210)   

ابن حبّان:٢٦٦٤أَخْبَرَنَا الْحُسَيْنُ بْنُ مُحَمَّدِ بْنِ مُصْعَبٍ قَالَ حَدَّثَنَا أَبُو سَعِيدٍ الْأَشَجُّ قَالَ حَدَّثَنَا أَبُو خَالِدٍ الْأَحْمَرُ عَنِ ابْنِ عَجْلَانَ عَنْ زَيْدِ بْنِ أَسْلَمَ عَنْ عَطَاءِ بْنِ يَسَارٍ عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ قَالَ

قَالَ رَسُولُ اللَّهِ ﷺ «إِذَا شَكَّ أَحَدُكُمْ فِي صَلَاتِهِ فَلْيُلْقِ الشَّكَّ وَلْيَبْنِ عَلَى الْيَقِينِ فَإِنِ اسْتَيْقَنَ التَّمَامَ سَجَدَ سَجْدَتَيْنِ فَإِنْ كَانَتْ صَلَاتُهُ تَامَّةً كَانَتِ الرَّكْعَةُ نَافِلَةً وَالسَّجْدَتَانِ نَافِلَةً وَإِنْ كَانَتْ نَاقِصَةً كَانَتِ الرَّكْعَةُ تَمَامًا لِصَلَاتِهِ وَالسَّجْدَتَانِ تُرْغِمَانِ أَنْفَ الشَّيْطَانِ»  

ذِكْرُ الْبَيَانِ بِأَنَّ الْبَانِيَ عَلَى الْأَقَلِّ إِذَا شَكَّ فِي صَلَاتِهِ عَلَيْهِ أَنْ يَسْجُدَ سَجْدَتَيِ السَّهْوِ قَبْلَ الصَّلَاةِ لَا بَعْدُ

ibnhibban:2667al-Ḥusayn b. Muḥammad b. Muṣʿab > ʿAbdullāh b. Saʿīd al-Kindī > Abū Khālid al-Aḥmar > Ibn ʿAjlān > Zayd b. Aslam > ʿAṭāʾ b. Yasār > Abū Saʿīd al-Khudrī

“The Messenger of Allah ﷺ said: ‘If anyone of you is uncertain about his prayer, let him put aside uncertainty and act upon that which is certain. When he has made sure his prayer is complete, then let him prostrate twice. Then if his prayer was complete, that (extra) Rak’ah will be counted as voluntary, and if his prayer was lacking, that Rak’ah will complete his prayer, and the two prostrations will rub the Satan’s nose in the dust.’” (Using translation from Ibn Mājah 1210)   

ابن حبّان:٢٦٦٧أَخْبَرَنَا الْحُسَيْنُ بْنُ مُحَمَّدِ بْنِ مُصْعَبٍ قَالَ حَدَّثَنَا عَبْدُ اللَّهِ بْنُ سَعِيدٍ الْكِنْدِيُّ قَالَ حَدَّثَنَا أَبُو خَالِدٍ الْأَحْمَرُ عَنِ ابْنِ عَجْلَانَ عَنْ زَيْدِ بْنِ أَسْلَمَ عَنْ عَطَاءِ بْنِ يَسَارٍ عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ قَالَ

قَالَ رَسُولُ اللَّهِ ﷺ «إِذَا شَكَّ أَحَدُكُمْ فِي صَلَاتِهِ فَلْيُلْقِ الشَّكَّ وَلْيَبْنِ عَلَى الْيَقِينِ فَإِنِ اسْتَيْقَنَ التَّمَامَ سَجَدَ سَجْدَتَيْنِ فَإِنْ كَانَتْ صَلَاتُهُ تَامَّةً كَانَتِ الرَّكْعَةُ نَافِلَةً وَالسَّجْدَتَانِ نَافِلَةً وَإِنْ كَانَتْ نَاقِصَةً كَانَتِ الرَّكْعَةُ تَمَامًا بِصَلَاتِهِ وَالسَّجْدَتَانِ تُرْغِمَانِ أَنْفَ الشَّيْطَانِ»  

nasai-kubra:587ʿImrān b. Yazīd > ʿAbd al-ʿAzīz > Zayd b. Aslam > ʿAṭāʾ b. Yasār > Ibn ʿAbbās

The Prophet ﷺ said: When one of you is in doubt about his prayer, and does not know how much he has prayed, three or four rak'ahs, he should pray one (additional) rak'ah and make two prostrations while sitting before giving the salutation. If the (additional) rak'ah which he prayed is the fifth one, he will make it an even number by these two prostrations. If it is the fourth one, the two prostrations will be a disgrace for the devil. (Using translation from Abū Dāʾūd 1026)   

الكبرى للنسائي:٥٨٧أَخْبَرَنِي عِمْرَانُ بْنُ يَزِيدَ قَالَ حَدَّثَنَا عَبْدُ الْعَزِيزِ قَالَ حَدَّثَنَا زَيْدُ بْنُ أَسْلَمَ عَنْ عَطَاءِ بْنِ يَسَارٍ عَنِ ابْنِ عَبَّاسٍ

أَنَّ رَسُولَ اللهِ ﷺ قَالَ «إِذَا شَكَّ أَحَدُكُمْ فِي صَلَاتِهِ فَلَمْ يَدْرِ أَصَلَّى ثَلَاثًا أَوْ أَرْبَعًا فَلْيَقُمْ فَلْيَرْكَعْ» يَعْنِي رَكْعَةً وَيَسْجُدُ سَجْدَتَيْنِ فَإِنْ كَانَتْ خَامِسَةً شَفَعَهَا بِسَجْدَتَيْنِ وَإِنْ كَانَتْ رَابِعَةٌ كَانَتِ السَّجْدَتَانِ تَرْغِيمًا لِلشَّيْطَانِ  

bayhaqi:3883Abū ʿAlī al-Rūdhbārī > Abū Bakr Muḥammad b. Bakr > Abū Dāwud > Muḥammad b. al-ʿAlāʾ > Abū Khālid > Ibn ʿAjlān > Zayd b. Aslam > ʿAṭāʾ b. Yasār > Abū Saʿīd al-Khudrī

when one of you is in doubt about his prayer (i.e, how much he has prayed), he should throw away his doubt and base his prayer on what he is sure of. When he is sure about the completion of his prayer, he should make two prostrations (at the end of the prayer). If the prayer is complete, the additional rak’ah and the two prostrations will be supererogatory prayer. If the prayer is incomplete, the additional rak’ahs will compensate it, and the two prostrations will be a disgrace for the devil. (Using translation from Abū Dāʾūd 1024)   

البيهقي:٣٨٨٣أَخْبَرَنَا أَبُو عَلِيٍّ الرُّوذْبَارِيُّ أنبأ أَبُو بَكْرٍ مُحَمَّدُ بْنُ بَكْرٍ ثنا أَبُو دَاوُدَ ثنا مُحَمَّدُ بْنُ الْعَلَاءِ ثنا أَبُو خَالِدٍ عَنِ ابْنِ عَجْلَانَ عَنْ زَيْدِ بْنِ أَسْلَمَ عَنْ عَطَاءِ بْنِ يَسَارٍ عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ قَالَ

قَالَ رَسُولُ اللهِ ﷺ إِذَا شَكَّ أَحَدُكُمْ فِي صَلَاتِهِ فَلْيُلْقِ الشَّكَّ وَلْيَبْنِ عَلَى الْيَقِينِ فَإِذَا اسْتَيْقَنَ التَّمَامَ سَجَدَ سَجْدَتَيْنِ فَإِنْ كَانَتْ صَلَاتُهُ تَامَّةً كَانَتِ الرَّكْعَةُ نَافِلَةً وَالسَّجْدَتَانِ وَإِنْ كَانَتْ نَاقِصَةً كَانَتِ الرَّكْعَةُ تَمَامًا لِصَلَاتِهِ وَكَانَتِ السَّجْدَتَانِ مُرْغِمَتَيِ الشَّيْطَانِ