Imaam Barbahaaree on the Manhaj of Dealing with the Rulers
Imaam al-Barbahaaree said:
"And that we do not contend with or attempt to take away the command from those assigned with it (i.e., the rulers) due to the saying of the Messenger: "There are three things towards which the heart of a Muslim never shows hatred or rancour:
1. Making ones action sincerely for the sake of Allaah,
2. Giving obedience to the rulers (wulatul-amr) and
3. Sticking to the group (jamaa'ah) for verily, their supplication encompasses those who are behind them (i.e. those whom they rule over)." 
This is confirmed in His saying:
"O you who believe! Obey Allaah and obey the Messenger, and those of you (Muslims) who are in authority".
And that the sword is not to be raised against (any of) the Ummah of Muhammad (sallallaahu alaihi wasallam).
And al-Fudayl said, "If I had a supplication that would be answered, I would not make it except for the leader (Imaam) because when the leader becomes righteous, the towns and servants become safe and secure."
Ibn al-Mubaarak said (in reference to the above saying of al-Fudayl), "O teacher of goodness, who would show boldness towards this besides you?"
[End of the words of Bukhaaree]
Imaam al-Barbahaaree (d. 329H) also said, "Whoever rebels against a Muslim ruler is one of the Khawaarij, has caused dissent within the Muslims, has contradicted the narrations and has died the death of the days of ignorance." (Sharhus-Sunnah [p.42])
The Khawaarij are a group who first appeared in the time of 'Alee. They split from his army and began the grave innovation of takfeer (declaring Muslims, rulers or the ruled, in their view guilty of major sins, to be unbelievers). The Prophet s warned against them in many authentic ahaadeeth, "They are the dogs of Hellfire"
He also informed us that they would continue to appear until the end of this world, saying, "A group will appear reciting the Qur'aan, it will not pass beyond their throats, every time a group appears it will be cut off, until the Dajjaal appears within them."
Imaam Al-Barbahaaree (d.329H) also said, "It is not permissible to fight the ruler or rebel against him even if he oppresses. This is due to the saying of the Messenger of Allaah to Aboo Dharr al-Ghifaaree, "Have patience even if he is an Abyssinian slave,"  and his saying to the Ansaar, "Have patience until you meet me at the Pool," (reported by Bukharee from Usayd ibn Hudayr). There is no fighting against the ruler in the Sunnah. It causes destruction of the Religion and the worldly affairs." Sharh-us-Sunnah, (p. 43).
Abu Bakr al-Aajurree (d.360H) said in ash-Sharee'ah (p. 28),
"It is not fitting for the one who sees the uprising of a khaarijee who has revolted against the Imaam, 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 the prayer, nor his constant fasting or his good and excellent words in knowledge when (it is clear to him that) this person's way and methodology (madhhab) is that of the Khawaarij."
And Ibn al-Qayyim (d.751H) said in Miftaah Daaris-Sa'aadah (1/119), "And as for Imaam Maalik, then Ibn al-Qaasim said, "I heard Maalik say, "Indeed there are a people who desire worship but squander the knowledge (being deprived of it) so they revolt against the Ummah of Muhammad with their swords. And if they had followed the knowledge, then it would have prevented them from doing that."
It is authentically reported from the Messenger (sallallaahu alaihi wasallam) in the hadeeth of 'Iyaad ibn Ghunum who said, "The Messenger of Allaah s said, "Whoever desires to advise the one with authority then he should not do so openly, rather he should take him by the hand and take him into seclusion (and then advise him). And if he accepts (the advice) from him then (he has achieved his objective) and if not, then he has fulfilled that which was a duty upon him."
 Reported by Ahmad (3/403) and Ibn Abee 'Aasim (2/521) with a saheeh isnaad.
And it is also related by Ibn Sa'ad in Tabaqaatul-Kubraa (7/163-165): A group of Muslims came to al-Hasan al-Basree (d.110H) seeking a verdict to rebel against al-Hajjaaj . So they said, "O Aboo Sa'eed! What do you say about fighting this oppressor who has unlawfully spilt blood and unlawfully taken wealth and did this and that?" So al-Hasan said, "I hold that he should not be fought. If this is the punishment from Allah, then you will not be able to remove it with your swords. If this is a trial from Allaah, then be patient until Allaah's judgment comes, and He is the best of judges."
So they left al-Hasan, disagreed with him and rebelled against al-Hajjaaj - so al-Hajjaaj killed them all. 
About them al-Hasan used to say, "If the people had patience, when they were being tested by their unjust ruler, it will not be long before Allaah will give them a way out. However, they always rush for their swords, so they are left to their swords. By Allaah! Not even for a single day did they bring about any good."
1. Taken from "The Creed of Imaam al-Bukhaaree".
2. This hadeeth has been reported from a group among the Companions and see Sunan at-Tirmidhee (no. 2657), al-Musnad (4/80, 82 183), 'Jami' ul-Usool (1/265) and Majma'uz-Zuwaa'id (1/137-139).
3. Reported from Ahmad and it is saheeh
4. Reported from Ibn Maajah and it is hasan.
5. Reported from Muslim
7. When changing the evil of the rulers, then this should be done by the scholars and not openly as is mentioned by a clear hadeeth of the Prophet, "When you wish to correct the sultan then take him by the hand in secret and advise him." [Aquidah at-Tahawiyah]
8. He was ath-Thaqafee, and is well known. Adh-Dhahabee said in Siyar A'laam in-Nubalaa (4/343) at the end of his biography, "We revile him and do not love him, rather we hate him for Allaah. He had some some good deed, but they are drowned in the ocean of his sins, and his affair is for Allaah!"
Prepared by Abu Talhah and Abu Iyaad
The Creed of Imaam Bukhaaree / Explanation of the Creed