We relate from the early generations in this matter …
Among the hallmarks of Ahl al-Sunnah wa’l-Jamāʿah in their dealings with those in authority is the conviction that listening to them and obeying them is obligatory in times of ease and hardship alike, whether the rulers are upright or corrupt. Obedience, however, is limited to what is lawful; should they command disobedience to Allah, there is no obedience to any creature if it involves disobeying the Creator. They offer such rulers sincere advice, refrain from praying against them, and instead pray for their rectification and well-being. They consider it impermissible to revolt against them, fight them, or withdraw the pledge of obedience from them—even when those rulers act tyrannically and unjustly—regarding rebellion as a newly-invented deviation.
The leader of the people of the Sunnah, the venerated Imām Aḥmad ibn Ḥanbal (may Allah have mercy on him), said: “The foundations of the Sunnah, according to us, are: holding fast to what the Companions of the Messenger of Allah ﷺ were upon, taking them as one’s model, abandoning innovations—for every innovation is misguidance—forsaking disputes, avoiding the company of the people of desires, and refraining from wrangling, argumentation, and quarrels in matters of religion.”