Sahih Muslim Book 020, Hadith Number 4574.
Chapter : The best and the worst of your rulers.
It has been narrated on the authority of Auf b. Malik al-Ashja'i who said that he heard the Messenger of Allah (may peace be upon him) say: The best of your rulers are those whom you love and who love you, upon whom you invoke God's blessings and who invoke His blessing upon you. And the worst of your rulers are those whom you hate and who hate you, who curse you and whom you curse. (Those present) said: Shouldn't we overthrow them at this? He said: No, as long as they establish prayer among you. No, as long as they establish prayer among you. Mind you! One who has a governor appointed over him and he finds that the governor indulges in an act of disobedience to God, he should condemn the governor's act, in disobedience to God, but should not withdraw himself from his obedience. Ibn Jabir said: Ruzaiq narrated to me this hadith. I asked him: Abu Miqdam, have you heard it from Muslim b. Qaraza or did he describe it to you and he heard it from 'Auf (b. Malik) and he transmitted this tradition of Allah's Messenger (may peace be upon him)? Upon this Ruzaiq sat upon his knees and facing the Qibla said: By Allah, besides Whom there is no other God, I heard it from Muslim b. Qaraza and he said that he had heard it from Auf(b. Malik) and he said that he had heard it from the Messenger of Allah (may peace be upon him).