What follows are brief summaries (largely excerpted from the links given below) of how the four orthodox Sunni Imams related to the government authorities of their day. At the very least, they all experienced a certain amount of tension and in most cases, they endured some serious reprisals at the hand of the state for challenging the authorities.
Imam Abu HanifaIn the year 146 A.H, Abu Hanifah was sent to prison by Mansur, the leader at the time, after the Imam’s refusal to state that Mansur was the rightful khalifa, as well as refusing the position of presidency of the supreme court in recompense. Whilst in prison Imam Abu Hanifah was thrashed with a stick. Mansur repented and sent the Imam money, only to be refused again. By now Imam Abu Hanifah had become well known and thousands flocked to meet and seek his opinion wherever he went. His imprisonment far from reduced his popularity, and Mansur realised that he would have to treat the Imam carefully, thus he allowed him to teach whilst still in prison. Mansur finally decided to do away with the great Imam and had him poisoned. Abu Hanifah feeling the effects of the poison, bent down in prayer and died in the month on Rajab. News of the Imam’s death reached far and wide, and thousands gathered at the prison. The city Qadi washed his body, and kept repeating "by God you were the greatest faqih and the most pious man of our time....".
Imam MalikImam Malik was known for his integrity and peity. He always lived up to his convictions. Neither fear nor favour could ever deflect him from the right path. He was among the members of the glorious society of early Islam who could not be purchased and whose undaunted courage always proved as a guiding star for the freedom fighters.
When he was aged twenty-five, the Caliphate passed into the hands of the Abbasids caliph Mansur who was his colleague. Mansur highly respected him for his deep learning. The Imam however, favoured the Fatimid Nafs Zakriya for the exalted office of the Caliph. When he learned that the people had taken the oath of fealty of Mansur, he said that since Mansur had forced people to do so, the oath was not binding them. He quoted a Tradition of the Prophet (sws) to the effect that a divorce by force is not legal. When Jafar, a cousin of Mansur, was posted as Governor of Medina, he induced the inhabitants of the Holy city to renew their oath of allegiance to Mansur. The Governor forbade him not to publicise his Fatwa in respect of forced divorce. Highly principled and fearless as he was, the defied the Governor’s orders and courageously persisted in his course. This infuriated the Governor, who ordered that the Imam be awarded 70 stripes, as punishment. According, seventy stripes were inflicted on the naked back of the Imam which began to bleed. Mounted on a camel in his bloodstaind clothes, he was paraded through the streets of Medina. This brutality of the Governor failed to cow down or unnerve the noble Imam. Caliph Mansur, when apprised of he matter, punished the Governor and apologised to the Imam.
Imam Muhammad ibn Idris al-ShafiAt the time of Harun ar-Rashid, he had an appointment in Yemen, as a judge in Najran. Sunnis portray that his devotion to justice, even when it meant criticizing the governor, caused him some problems, and he was taken before the Caliph, falsely accused of aiding the Alawis in a revolt. At this time, al Shaybani was the chief justice, and his defense of ash-Shafi'i, coupled with ash-Shafi'i’s own eloquent defense, convinced Harun ar-Rashid to dismiss the charge, and to direct al Shaybani to take ash-Shafi'i to Baghdad. In Baghdad, he developed his first madhab, influnced by the teachings of both Imam Abu Hanifa and Imam Malik. Thus, his work there is known as “al Madhab al Qadim lil Imam as Shafi’i,” or the Old School of ash-Shafi'i.
Imam Ahmad Ibn HanbalThe case of the persecution faced by Imam Ahmad is different from the previous cases for several reasons. Firstly (and this may just be a result of my own reading choices) but it seems that his suffering is more well-known than the above-mentioned cases. Secondly (and this might explain the first difference) Imam Ahmad's persecution is much more theological than political.
Under the reign of the Caliph at the time, Al-Ma'mun, a "heretical" Mu'tazilite theology become dominant and the religious authorities persecuted the orthodox scholars who disagreed including Imam Ahmad.
For refusing to follow the theology Al-Ma'mun tried to impose, Imam Ahmad was put in irons and was ordered to be delivered into the Caliph's presence. On the way, Imam Ahmad supplicated to Allah to prevent him from meeting Al-Ma’mun. His prayer was answered in the sudden death of al-Ma’mun. Unfortunately, the Inquisition continued into the reign of the next two caliphs and Imam Ahmad endured flogging, imprisonment and exile during this period. But with the death of the Caliph Al-Wathiq and the rise of the new Caliph Al-Mutawakkil, the persecution ended and Imam Ahmad regained some measure of freedom.
The Life of Imam Abu Hanifah by Maida Malik
Imam Malik by Kh. Jamil Ahmad
Wikipedia:
Imam Muhammad ibn Idris ash-Shafi`iWikipedia:
Imam Ahmad Ibn Hanbal