At ‘Isha’ prayer yesterday I entered the mosque when the imam was reciting Soorat al-‘Alaq in the second rak’ah and I joined the prayer. At the end of the soorah there is a verse where a prostration is required, but the imam said takbeer after this verse. Some of the worshippers bowed but most of them prostrated. I prostrated with them because I could not see the imam. After that the imam stood up again (by saying Sami’a Allaahu liman hamidah) and we realized that we had made a mistake and we completed the prayer with the imam, until he said the salaam. After that I made up the rest of the prayer and I did two rak’ahs instead of one, and I did the prostration of forgetfulness. Is what I did permissible, or should I repeat my prayer?.
If the matter is as described, then your prayer is valid, praise be to Allaah.
The reason for that is that the one who misses bowing with the imam, for a reason like the confusion that you mention, has to do it and then follow the imam, and in that case he is forgiven for his delay in following the imam. If he does not do it, then the rak’ah is invalid, and he has to do it again after the imam says the salaam, and you did that.
It says in Kashshaaf al-Qinaa’ (1/466): If the person praying behind the imam misses an essential part of the prayer for a reason such as sleeping or confusion or because the imam moves too quickly, he should do it and catch up because that is obligatory, because he can catch up with him without any problem, so he has to do that, and the rak’ah will be valid and will count. If he cannot make up what he missed and then catch up with the imam, because that is not possible, then the rak’ah is not valid, rather it is cancelled out because an essential part of it has been omitted. End quote.