Abdullah bin Umar reported,

The Messenger of Allah ﷺ was sitting among a group of his companions when he asked them, "Do you not know that I am the Messenger of Allah to you?"They replied, "Indeed, we bear witness that you are the Messenger of Allah."He asked, "Do you not know that whoever obeys me has obeyed Allah, and that obedience to me is part of obedience to Allah?"They replied, "Indeed, we bear witness that whoever obeys you has obeyed Allah, and that obedience to you is part of obedience to Allah."He said, "Then it is part of obedience to Allah that you obey me, and it is part of obedience to me that you obey your leaders. If they pray sitting, then pray sitting."In another wording, "your imams" appears instead of "your leaders."

Azami 15651

Sahih

عن ابن عمر

أن رسول الله ﷺ كان في نفر من أصحابه، فقال: ألستم تعلمون أني رسول الله إليكم؟ قالوا: بلى نشهد أنك رسول الله قال: ألستم تعلمون أنه من أطاعني، فقد أطاع الله، ومن طاعة الله طاعتي؟ قالوا: بلى، نشهد أنه من أطاعك فقد أطاع الله، ومن طاعة الله طاعتك، قال: فإن من طاعة الله أن تطيعوني، ومن طاعتي أن تطيعوا أمرائكم، وإن صلوا قعودا فصلوا قعودا. وفي لفظ أئمتكم بدل أمرائكم.

الأعظمي 15651صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Holding fast to the Quran and the Sunnah
Chapter
Images and image-makers
Section
Obligation of adhering to the Book and the Sunnah
Numbering
Jami al-Kamil 15651 (2nd edition)
Azami 15651