Sayyiduna Abu Layla al-Ash'ari (may Allah be pleased with him), who was a Companion of the Messenger of Allah (peace and blessings be upon him), narrates from the Messenger of Allah (peace and blessings be upon him) that he (peace and blessings be upon him) said: "Hold firmly to obedience to your rulers and do not oppose them, for obedience to them is obedience to Allah and disobedience to them is disobedience to Allah. Allah has sent me only to call to His path with wisdom and good admonition, so whoever succeeds me in that is my ally. And whoever is put in charge of any of your affairs and acts otherwise, upon him is the curse of Allah, the angels and all the people. Soon rulers will come over you who, if mercy is sought from them, will not show mercy; if rights are asked of them, will not give them; and if they are enjoined to do good, will reject it. You will keep away from them and your community will scatter, until whatever they impose on you, you will bear it willingly or unwillingly. So the least of the right due to you is that you neither take a stipend from them nor attend their gatherings."
Hadith Referenceالمعجم الكبير للطبراني / مسند من يعرف بالكنى / 19138