When he had prayed two rakahs, he stood up without sitting. Those behind him said tasbih to alert him, but he gestured to them to stand. When he finished his prayer, he gave the salam, then performed the two prostrations of forgetfulness, gave the salam again, and said, "This is how the Messenger of Allah ﷺ did it."
حدثنا عبد الله بن عبد الرحمن أخبرنا يزيد بن هارون عن المسعودي عن زياد بن علاقة قال صلى بنا
فلما صلى ركعتين قام ولم يجلس فسبح به من خلفه فأشار إليهم أن قوموا فلما فرغ من صلاته سلم وسجد سجدتي السهو وسلم وقال هكذا صنع رسول الله ﷺ
[Hasan] Abu Dawud also narrated it in the Book of Prayer, chapter on one who forgets to recite the tashahhud while sitting, no. 1037, from the hadith of Yazid through the same chain. The hadith has corroborating narrations in Tahawi (Maani al-Athar 1/440) and elsewhere, and it is also found in Musnad Darimi, no. 1509.