An-Nisāʾ: 59
"O you who have believed..."
When He commanded the rulers to render trusts to their rightful owners and to judge with justice, He commanded the people to obey them and submit to their rulings.
The intended meaning of "those in authority among you" (ūlī al-amr minkum) is the rulers of truth. As for the rulers of tyranny, Allah and His Messenger are free of them; therefore, they are not conjoined with Allah and His Messenger in the obligation of obedience. Rather, the conjunction is only between Allah, His Messenger, and the rulers who align with them in preferring justice, choosing the truth, commanding both, and forbidding their opposites—such as the Rightly Guided Caliphs and those who followed them in excellence.
The Caliphs used to say: "Obey me as long as I am just among you; if I deviate, then I have no claim to your obedience."
It is narrated that Abū Ḥāzim was asked by Maslamah ibn ʿAbd al-Malik: "Are you not commanded to obey us in His saying: 'And those in authority among you'?" He replied: "Have you not been stripped of that authority when you deviate from the truth by His saying: 'And if you disagree over anything, refer it to Allah and the Messenger'?"
It is also said that they are the commanders of military expeditions. It is narrated from the Prophet (ﷺ): "Whoever obeys me has obeyed Allah, and whoever disobeys me has disobeyed Allah; and whoever obeys my commander has obeyed me, and whoever disobeys my commander has disobeyed me." (Authentic).
It is also said that they are the religious scholars who teach people the religion, command them to do good, and forbid them from evil.
"And if you disagree over anything..."
If you and those in authority among you differ regarding any matter of religion, refer it to Allah and His Messenger—meaning, return to the Book and the Sunnah regarding it.
How could obedience to tyrannical rulers be binding? Allah has qualified the command to obey those in authority with conditions that leave no room for doubt: He first commanded them to render trusts and judge with justice, and finally commanded them to return to the Book and the Sunnah in matters of ambiguity. Tyrannical rulers do not render trusts, do not judge with justice, and do not refer anything to the Book of Allah or the Sunnah. They only follow their desires wherever they lead them. Thus, they are stripped of the attributes of those who are "those in authority" in the sight of Allah and His Messenger, and the most appropriate name for them is "usurping thieves."
A reference to the act of referring back to the Book and the Sunnah.
For you and more beneficial.
Meaning, the best in final consequence. It is also said: "Better in interpretation than your own interpretation."
"Have you not seen those who claim to have believed in what was revealed to you and what was revealed before you? They wish to refer legislation to the Ṭāghūt (false idols/tyrants), while they were commanded to disbelieve in it; and Satan wishes to lead them far astray. And when it is said to them, 'Come to what Allah has revealed and to the Messenger,' you see the hypocrites turning away from you in aversion. So how [will it be] when disaster strikes them because of what their hands have put forth, then they come to you swearing by Allah, 'We intended nothing but good conduct and reconciliation'? Those are the ones of whom Allah knows what is in their hearts, so turn away from them, but admonish them and speak to them a far-reaching word." (60-63)