The Prophet ﷺ said, "There will come to rule over you leaders whose actions you will recognize as right and others as wrong. Whoever rejects what is wrong is absolved, and whoever hates it is safe, but whoever is pleased with it and follows along is guilty."It was asked, "Messenger of Allah, shall we not fight them?"He replied, "No, not as long as they pray."
حدثنا الحسن بن علي الخلال حدثنا يزيد بن هارون أخبرنا هشام بن حسان عن الحسن عن ضبة بن محصن
عن النبي ﷺ قال إنه سيكون عليكم أئمة تعرفون وتنكرون فمن أنكر فقد بريء ومن كره فقد سلم ولكن من رضي وتابع فقيل يا رسول الله أفلا نقاتلهم قال لا ما صلوا
Reference: Also narrated by Muslim in the Book of Leadership, Chapter on the obligation to denounce rulers when they violate the Sharia and the prohibition of fighting them as long as they pray, and similar matters, hadith no. 1854, from the hadith of Hisham bin Hassan, with the same chain.