If he starts to get up for a fifth rak‘ah and the people say “Subhaan-Allah” before he has stood up completely, what should he do?
Question

I was leading the people in prayer as an imam, then I got confused in the fourth rak‘ah, so instead of sitting for the tashahhud, I started to get up for another rak‘ah. The worshippers alerted me to that [by saying “Subhaan-Allah”] and I did not stand up completely; in other words, I only moved a little, as you know, then I sat back down and completed the prayer. My question is: should the two prostrations of forgetfulness in this case be done before the salaam or after it? Please note that I only moved approximately twenty centimetres.
Praise be to Allah.If the worshipper gets confused and wants to stand up for an extra rak‘ah, such as a fifth rak‘ah in a four-rak‘ah prayer such as Zuhr, or a fourth rak‘ah in a three-rak‘ah prayer such as Maghrib, or a third rak‘ah in a two-rak‘ah prayer such as Fajr, then what he must do is sit back down immediately without saying takbeer, because if he does not sit down, he will be adding something to the prayer deliberately, and that renders the prayer invalid.
With regard to the ruling on the prostration of forgetfulness, there are two scenarios:
The first scenario:
If he remembers after his thighs have left his calves, or his knees or buttocks have left the ground, then he should do the prostration of forgetfulness after the salaam according to the more correct view, because he added something to his prayer.
Ibn Qudaamah said in al-Mughni (2/428):
“If he prays five [rak‘ahs]” means in a four-rak‘ah prayer. So if he stands up for a fifth rak‘ah in a four-rak‘ah prayer, or for a fourth rak‘ah in Maghrib, or for a third rak‘ah in Fajr, he must go back as soon as he remembers, and sit down.
If he recited the tashahhud [and as-salaat al-Ibraaheemiyyah] following the rak‘ah which completed his prayer, he should do the prostration of forgetfulness then say the salaam.
But if he had recited the tashahhud without blessings upon the Prophet (blessings and peace of Allah be upon him) [as-salaat al-Ibraaheemiyyah], he should do so, then do the prostration for forgetfulness and say the salaam. If he did not recite the tashahhud, he should recite it [and as-salaat al-Ibraaheemiyyah] and do the prostration of forgetfulness, then say the salaam.
If he did not remember until he had finished his prayer, he should do the two prostrations of forgetfulness as soon as he remembers, and recite the tashahhud [and as-salaat al-Ibraaheemiyyah], and his prayer will be valid.
This is the view of ‘Alqamah, al-Hasan, ‘Ataa’, az-Zuhri, an-Nakha‘i, Maalik, al-Layth, ash-Shaafa‘i, Ishaaq, Abu Thawr… End quote.
Ibn Jizziy said: If someone gets up for an extra rak‘ah in an obligatory prayer, he should sit back down when he remembers, and do the prostration [of forgetfulness] after the salaam.
End quote from al-Qawaaneen al-Fiqhiyyah (p. 53).
The second scenario:
If he remembers before he gets up, or before his thighs leave his calves or his knees leave the ground, then he does not have to do the prostration of forgetfulness, because he is still sitting.
Ibn ‘Uthaymeen (may Allah have mercy on him) said in ash-Sharh al-Mumti‘ (3/378): If he remembers before he gets up, some of the scholars said: That is, before his thighs leave his calves – and some of them said: before his knees leave the ground; the meaning is similar, because when his knees leave the ground, he has got up, and when his buttocks leave his calves, he has also got up.
But if he remembers before he gets up, then he should carry on, and he does not have to do the prostration of forgetfulness. This is the ruling on this matter according to the author [meaning the author of az-Zaad]. End quote.
It says in at-Ta‘leeqaat ‘ala al-Kaafi (1/481): If he does not get up in the sense that he is no longer regarded as sitting, then he does not have to do the prostration of forgetfulness; but if he moves upwards so that he is no longer regarded as sitting [then he must do the prostration of forgetfulness].
Some of the scholars mentioned as a guideline on that that his buttocks leave his heels – in that case he must do the prostration of forgetfulness, because he has added something to the prayer.
And it was said that he does not have to do the prostration of forgetfulness if he sits back down before he has stood up completely, because getting up is not in and of itself one of the essential parts of the prayer , so if he gets up this is not regarded as adding something [to the prayer], so he does not have to do the prostration of forgetfulness. End quote.
And Allah knows best.