Jabir bin Abdullah reported,

The Messenger of Allah ﷺ fell ill, so we prayed behind him while he was seated, and Abu Bakr was relaying his takbir to the people. He turned toward us and saw that we were standing, so he gestured for us to sit down, and we completed the prayer seated as he was praying.When he gave the closing salam, he said, "You were just about to do what the Persians and Romans do, standing before their kings while the kings remain seated. Do not do that. Follow your imams. If he prays standing, then pray standing, and if he prays seated, then pray seated."

Azami 2608

Sahih

عن جابر قال

اشتكى رسول الله ﷺ فصلينا وراءه وهو قاعد، وأبو بكر يسمع الناس تكبيره. فالتفت إلينا فرآنا قياما، فأشار إلينا فقعدنا، فصلينا بصلاته قعودا، فلما سلم قال: إن كدتم آنفا لتفعلون فعل فارس والروم، يقومون على ملوكهم، وهم قعود، فلا تفعلوا ائتموا بأئمتكم. إن صلى قائما فصلوا قياما، وإن صلى قاعدا فصلوا قعودا.

الأعظمي 2608صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Prayer
Chapter
What is prohibited and disliked in prayer
Section
Concession for turning in prayer when there is a need
Numbering
Jami al-Kamil 2608 (2nd edition)
Azami 2608