Sahih Muslim Book 020, Hadith Number 4518.
Chapter : Obedience to the ruler is forbidden in matters sinful, but is otherwise obligatory.
It has been narrated on the authority of Abu Huraira that the Holy prophet (may peace be upon him) said: Whoso obeys me obeys God, and whoso disobeys me disobeys God. Whoso obeys the commander (appointed by me) obeys me, and whoso disobeys the commander disobeys me. The same tradition transmitted by different persons omits the portion: And whose disobeys the commander disobeys me.