Sahih Muslim Book 020, Hadith Number 4535.
Chapter : Obedience to the ruler is forbidden in matters sinful, but is otherwise obligatory.
It has been narrated on the authority of Abu 'Abd al-Rahman from 'Ali that the Messenger of Allah (may peace be upon him) sent a force (on a mission) and appointed over them a man. He kindled a fire and said: Enter it. Some people made up their minds to enter it (the fire), (carrying out the order of their commander), but the others said: We fled from the fire (that's why we have come into the fold of Islam). The matter was reported to the Messenger of Allah (may peace be upon him). He said to those who Contemplated entering (the fire at the order of their commander): If you had entered it, you would have remained there until the Day of Judgment. He commanded the act of the latter group and said: There is no submission in matters involving God's disobedience or displeasure. Submission is obligatory only in what is good (and reasonable).