عن أبي هريرة رضي الله عنه مرفوعاً: «من أطاعني فقد أطاع الله، ومن عصاني فقد عصى الله، ومن يطع الأمير فقد أطاعني، ومن يعص الأمير فقد عصاني».
The Prophet (may Allah's peace and blessings be upon him) clarified that obedience to him is obedience to Allah. The Prophet does not order his followers with anything except the legislation that Allah legislated for him and his followers. When he commands us to do something, then indeed it is from Allah's legislation. So whoever obeyed the Prophet indeed obeyed Allah, and whoever disobeys the Prophet disobyed Allah.
If someone obeys the leader, then he has indeed obeyed the Prophet, and likewise, if he disobeys the leader, then he has disobeyed the Prophet; that is because the Prophet ordered obedience to the leader in many Hadīths, except if the leader's order involves disobedience (to Allah and His Messenger).
Download for free and never miss a prayer again