Abdul-Rahman bin Awf reported,

I heard the Messenger of Allah ﷺ say, "When one of you is uncertain whether he has prayed one rakah or two, let him count it as one. When he is uncertain whether he has prayed two or three, let him count it as two. When he is uncertain whether he has prayed three or four, let him count it as three. Then let him complete what remains of his prayer, so that any doubt falls on the side of having prayed extra. Then let him perform two prostrations while seated, before giving the salam."

Ibn Majah 1209

Hasan

حدثنا أبو يوسف الرقي محمد بن أحمد الصيدلاني حدثنا محمد بن سلمة عن محمد بن إسحق عن مكحول عن كريب عن ابن عباس

عن عبد الرحمن بن عوف قال

سمعت رسول الله ﷺ يقول إذا شك أحدكم في الثنتين والواحدة فليجعلها واحدة وإذا شك في الثنتين والثلاث فليجعلها ثنتين وإذا شك في الثلاث والأربع فليجعلها ثلاثا ثم ليتم ما بقي من صلاته حتى يكون الوهم في الزيادة ثم يسجد سجدتين وهو جالس قبل أن يسلم

ابن ماجه 1209حسن
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Establishing prayer and the sunnah regarding it
Chapter
Whoever is uncertain in his prayer and returns to what is certain
Numbering
Darussalam 1209
Ibn Majah 1209