In chapter 2 of his book ma rawahu al-asatin fi ‘adam al maji’ ila al-salatin (‘the reports concerning not appearing at the courts of rulers’), Imam Jalal al-Din al-Suyuti* writes:
Ibn ‘Adi has narrated from Abu Hurayrah (ra) that the Messenger of Allah ﷺ said, ‘In Hell, there is a valley from which the Fire seeks refuge seventy times a day. Allah (swt) has prepared it for the jurists who act to be admired by people. And the most hated of people to Allah (swt) is the scholar of the ruler.’
Ibn Bilal, Hafiz Abu al-Fityan al-Dahatnani, in the book al-Tahdhir min ‘Ulama’ al-Su’, and Al-Rafi’i in Tarikh Qazwin, all narrated from Abu Hurayrah (ra) that the Messenger of Allah ﷺ said, ‘The most hated of people in the universe to Allah (swt) is the scholar that visits the rulers.’
The wording of Abu al-Fityan is: ‘The most worthless of people to Allah, is the scholar that visits the rulers.’
Ibn Majah narrated from Abu Hurayrah (ra) that the Messenger of Allah ﷺ said, ‘The most hated of reciters to Allah are those that visit the rulers.’
Al-Daylami narrated in Musnad al-Firdaws from Abu Hurayrah (ra) that the Messenger of Allah ﷺ said, ‘If you see a scholar mixing frequently with the ruler, then know that he is a worldly person.’
Ibn Majah narrated, with a chain of transmission to his trustworthy narrators, from Ibn ‘Abbas (ra) that the Prophet ﷺ said:
“There are people from my ummah that study the religion and recite the Qur’an. They will say, ‘We go the rulers for our share in the world. But we avoid them in our religious matters.’ However, that is not the case. Just as one who enters a thorny bush can expect to be pricked by a thorn, one can only expect to be afflicted with sinfulness from nearness to them.”
Al-Tabarani narrated in his Awsat, with an authentic chain of transmission to his trustworthy narrators, from Thawban (ra), the freed slave of the Messenger of Allah ﷺ, that he said:
‘O Messenger of Allah! Am I from the people of your house?’ But he remained silent. I asked him a second and third time. On the third, he said, ‘Yes. As long as you do not remain near a fortified gate or go to the ruler seeking anything from him.’
Hafiz al-Mundhiri said, in Al-Targhib wa al-Targhib, ‘The meaning of “the fortified gate” is the gate of the ruler, or other leaders.’
[Cf. English translation of ma rawahu al-asatin fi ‘adam al maji’ ila al-salatin by Talut Dawood, Imam Ghazali Institute, 2021, pp. 32-33]
*Suyuti is ‘Abd al-Rahman ibn Abu Bakr ibn Muhammad ibn Sabiq al-Din, Jalal al-Din al-Suyuti, born in 849/1445. He was a Shafi‘i mujtahid Imam, Sufi, hadith master (hafiz), and historian, a prolific writer who authored works in virutually every Islamic science. Raised as an orphan in Cairo, he memorised the Qur’an at eight, then several complete works of Sacred Law, fundamentals of jurisprudence, and Arabic grammar; after which he devoted himself to studying the Sacred Sciences under some of the foremost sheikhs of the time in each discipline.
He travelled to gain Sacred Knowledge to Damascus, the Hijaz, Yemen, India, Morocco, and the lands south of Morocco, as well as the centres of learning in Egypt, such as Mahalla, Dumyat and Fayyum.
When he reached forty years of age, he abandoned the company of men for the solitude of the Garden of al-Miqyas by the side of the Nile, avoiding his former colleagues as though he had never known them, and it was here he authored most of his nearly six hundred books and treatises. Wealthy Muslims and princes would visit him with offers of money and gifts, but he put all of them off, and when the sultan requested his presence a number of times, he refused. Blessed with success in his years of solitude, it is difficult to name a field in which Suyuti did not make outstanding contributions, among them his ten-volume hadith work, Jam‘ al jawami‘ [The collection of collections]; his Qur’anic exegesis Tafsir al-Jalalayn [The commentary of the two Jalals]; his classic commentary on the sciences of hadith Tadrib al-rawi fi sharh Taqrib al-Nawawi [The training of the hadith transmitter: an exegesis of Nawawi’s “The facilitation”]; and many others. A giant among his contemporaries, he remained alone, producing a sustained output of scholarly writings until his death in Cairo at sixty years of age in 911/1505.
[Excerpted from Reliance of the Traveller by Shaykh Nuh Keller, p. 1100]
NB
Ibn al-Jawzi says: “We have seen among the Sufis and scholars those who cheat the rulers in order to get what they have. Among them are those who flatter them or try to impress them with their virtue and knowledge, and among them are those who praise them in ways that are forbidden, and among them are those who stay silent regarding evil deeds the rulers do, and beyond these of flattery and servility…” [The Sayings of Ibn al-Jawzi, translated by Ikram Hawramani, Steward Publishing, 2018, pp. 9-10]
For more on this topic, please read Should Pro-Government Scholars be Criticized?
Regarding the UAE (pictured above) and tyrants etc., see here and here