Muslim reported that
Ibn Umar said the Prophet ordered every Muslim to obey their leader unless commanded to do something bad, in which case they must neither obey nor listen. Muslim also reported that Ibn Malik said the best leader is the one where mutual love exists between him and the people, and the worst leader generates mutual hate. However, even in the latter case,
fighting the Khalifa is prohibited unless he enters kufr by stopping prayers or zakat for example. Ibn As-Samit reported that
the Prophet said to obey him in all things and situations, and not to remove the leaders unless they openly practice kufr. Abu Daud reports from Ibn Ujrah that the Prophet entered a masjid, and said there will come leaders after him who disobey the Qur'an and Allah. Those who help them are not of the Muslims, but if someone opposes them, he or she is of the Prophet's people.
Courtesy of www.usc.edu