Imam Abu Ya'la (may Allah have mercy on him) narrated with his chain that Sayyiduna Anas bin Malik (may Allah be pleased with him) related that Sayyiduna Mu'adh (may Allah be pleased with him) said: "O Messenger of Allah (peace and blessings be upon him), what do you say if commanders (rulers) are set over us who do not act according to your pure Sunnah and do not follow your command; what do you order us to do regarding them in that case?" He (peace and blessings be upon him) said: "There is no obedience owed to one who does not obey Allah."
Imam Abu Ya'la al-Mawsili (may Allah have mercy on him) recorded this hadith in his Musnad, and this narration supports the legal principle that obedience to a creature is not permissible in disobedience to the Creator.
Hadith Referenceالمطالب العالية بزوائد المسانيد الثمانية / كتاب الخلافة والإمارة / 2162
Hadith Gradingمحدثین:إسناده ضعيف
Hadith Takhrij«حکم الحدیث المطالب العالیہ محققاً تنسیق د. سعد بن ناصر بن عبد العزيز الشَّثري- مکتبہ شاملہ :إسناده ضعيف. » «أخرجه الأحاديث المختارة للضياء برقم: 2341، وأخرجه مسند أحمد برقم: 13427، وأخرجه مسند أبي يعلى برقم: 4046»