Sayyiduna Awf bin Malik al-Ashja'i (may Allah be pleased with him) said that the Messenger of Allah (peace and blessings be upon him) said: "The best of you and the best of your rulers are those whom you love and who love you, for whom you pray and who pray for you; and the worst of you and the worst of your rulers are those whom you hate and who hate you, whom you curse and who curse you." The Companions said: Then should we not rebel against them, O Messenger of Allah? He (peace and blessings be upon him) said: "No, as long as they establish the five prayers. However, whoever has a ruler over him and sees him committing some disobedience to Allah, let him hate that disobedience. Beware! Do not withdraw your hand from obedience."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 15206