Sheikh Ibn Baaz (RH) was asked:
There are those who hold that the perpetration of major sins by the rulers obligates revolting against them, and endeavoring to remove them, even if this causes some harm to the Muslims in the country. And recent occurrences like this have started to happen in places within our Islamic world, so what is your opinion – O noble Shaykh – concerning this?

Whosoever sees something from his leader of sin, then let him hate whatever occurs from sin. And let him not remove his hand from obedience, since whoever removes his hand from disobedience and splits off from the Jamaa’ah (united body), then he dies the death of Jaahiliyyah (pre-Islaamic times of ignorance).’’ 1

And the Prophet said: ‘‘The person must obey in whatever he loves, and in whatever he hates, in ease and in hardship, in willingness and un-willingness; except if he is commanded to disobey Allaah. So if he is commanded to disobey Allaah, then he should not listen, not should he obey.’’2

And the Companions asked him: O Messenger of Allaah! When you mentioned that there will be rulers, ‘you will approve of some things from them, and disapprove of others things.’ They said: So what do you command us to do? He said: ‘‘Give them their right, and invoke Allaah, since He is with you.’’ ’Ubaadah (r ) said: ‘‘We gave the oath of allegiance to the Messenger of Allaah that we would not oppose the command, not its people.’’ He said: ‘‘Except if you were to see clear disbelief (kurfan bawaahan) about which you have a proof from Allaah.’’ 3

Rather, it is obligatory to avert the evil by removing it. As for averting the evil with a greater evil, then that is not permissible by consensus of the Muslims. So if this group which wishes to remove the ruler who has committed clear disbelief, has the power to remove him, and to replace him with a good righteous leader, without bringing about that which is a greater evil and corruption upon the Muslims, and a greater evil than this ruler, then there is no problem. And for if this revolting will bring about a greater corruption, and betraying the trust, and oppression upon the people, and murdering those who do not deserve it, and great evils other than this, then it is not permissible.4

1.Related by al-Bukhaaree (13/5) and Muslim (no. 1849)
2.Related by al-Bukhaaree (4/203)
3.Related by Muslim (6/17)
4.Imaam Aboo Bark al-Aajurree (d.360H) – rahimahullaah – said: ‘‘It is not permissible for the one who sees the uprising of a khaarijee who has revolted against the leader, whether he is just or oppressive – so this person has revolted and gathered a group behind him, has pulled out his sword and has made lawful the killing of Muslims – it is not fitting for the one who sees this, that he becomes deceived by this person’s recitation of the Qur‘aan, the length of his standing in Prayer, nor his constant fasting, nor his good and excellent words in knowledge when it is clear to him that this person’s way and methodology is that of the Khawaarij.” Refer to the book ash-Sharee’ah (p. 28)