Is it valid to pray three rak'ahs with the intention of a supererogatory prayer behind an imam who is praying Dhuhr, or must one complete it as four rak'ahs?
You intended to perform a voluntary prayer with an unknown number of rak'at, because you do not know which rak'ah your Imam is in, and you intended to say the taslim when he says his. This is permissible according to the Shafi'is, as voluntary prayers that are not tied to a specific reason or time have no limit to their number. So, if one begins a voluntary prayer without intending a specific number, they may say the taslim after one rak'ah, or after two rak'at or more. And if one prays an unknown number of rak'at and then says the taslim, it is valid, and you are hoped to be rewarded for your prayer.
Summarized from the full answer at Ftawy · reviewed Sep 2, 2026
Read the full answer on Ftawyhttps://ftawy.com/en/questions/188959