Sayyiduna Awf bin Malik (may Allah be pleased with him) said that the Messenger of Allah (peace and blessings be upon him) said: "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 your rulers are those whom you hate and who hate you, whom you curse and who curse you." We said: O Messenger of Allah, then should we not rebel against them at that time? He (peace and blessings be upon him) said: "No, as long as they establish the prayer among you. And whoever has a ruler over him and sees in him some disobedience to Allah, let him hate that disobedience, and let him not withdraw his hand from obedience."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 15208