The Messenger of Allah ﷺ once rode a horse and was thrown from it, injuring his right side. He prayed one of the prayers while seated, and we prayed behind him seated as well.When he finished, he said, "The imam is appointed only to be followed. When he prays standing, pray standing. When he bows, bow. When he rises, rise. When he says, 'Allah hears those who praise Him,' say, 'Our Lord, to You belongs all praise.' And when he prays sitting, all of you pray sitting."
حدثنا القعنبي عن مالك عن ابن شهاب
أن رسول الله ﷺ ركب فرسا فصرع عنه فجحش شقه الأيمن فصلى صلاة من الصلوات وهو قاعد وصلينا وراءه قعودا فلما انصرف قال إنما جعل الإمام ليؤتم به فإذا صلى قائما فصلوا قياما وإذا ركع فاركعوا وإذا رفع فارفعوا وإذا قال سمع الله لمن حمده فقولوا ربنا ولك الحمد وإذا صلى جالسا فصلوا جلوسا أجمعون
Bukhari narrated it in the Book of Adhan, chapter, "The imam is only appointed to be followed," hadith no. 689, and Muslim in the Book of Prayer, chapter on the follower following the imam, hadith no. 411, both from the hadith of Malik through this chain. It is also found in Muwatta (1/135, Yahya's version).