The Messenger of Allah (ﷺ) stood up (at the end of two rak'ahs) when he had to sit and…

Sahih Muslim Book 5 Hadith 109

Sahih Muslim #570 c

The Book of Mosques and Places of Prayer 5:109

'Abdullah b. Malik ibn Buhaina al-Asadi reported:

The Messenger of Allah (ﷺ) stood up (at the end of two rak'ahs) when he had to sit and proceeded on with the prayer. But when he was at the end of the prayer, he performed a prostration before the salutation and then pronounced the salutation.

Chapter: As-Sahw (forgetfulness) in prayer and prostrating to compensate for it

Grade: Sahih