It is narrated from Sayyiduna Anas bin Malik (may Allah be pleased with him) that Sayyiduna Mu'adh (may Allah be pleased with him) said: "O Messenger of Allah (peace and blessings be upon him)! What is your view: if rulers are set over us who neither follow your Sunnah nor act according to your command, then what do you command me regarding them?" The Messenger of Allah (peace and blessings be upon him) said: "There is no obedience owed to one who does not obey Allah Almighty."
Hadith Referenceمسند أبي يعلى الموصلي / مسند أنس بن مالك / 4046
Hadith Takhrij«قال سعيد بن محمد السناري: ضعيف» «أخرجه مسند أحمد برقم: 12813، وأخرجه فتح الباري برقم: 6725، وأخرجه مجمع الزوائد ومنبع الفوائد برقم: 9141، وأخرجه الأحاديث المختارة برقم: 2341، وأخرجه إتحاف الخيرة المهرة بزوائد المسانيد العشرة برقم: 4226، مسند ابویعلیٰ ترقیم الاثری: 4033»