The World Federation One Stop Fiqh

Ruling 1493

If a person doubts whether he is in the last rukūʿ of the first rakʿah or the first rukūʿ of the second rakʿah, and having thought about it he does not find an answer, his prayer is invalid. However, if, for example, he doubts whether he has performed four or five rukūʿs, in the event that his doubt arises before he bends down for sajdah, he must perform the rukūʿ about which he doubts. However, if he has already bent down for sajdah, he must dismiss his doubt.