It is narrated from Sayyiduna Awf bin Malik (may Allah be pleased with him) that the Prophet (peace and blessings be upon him) said: "The best of your rulers are those whom you love and who love you, for whom you supplicate to Allah and who supplicate for you; and the worst of your rulers are those whom you hate and who hate you, whom you curse and who curse you." It was said: O Messenger of Allah, then should we not rebel against them? He (peace and blessings be upon him) said: "No, as long as they establish the prayer among you. So if you see in your ruler something you dislike, then hate his deed, and do not withdraw your hand from obedience."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 15207