In the Islamic tradition, it was considered blameworthy for scholars to associate with rulers, especially if they were tyrants. The polymath and mujtahid, Imam Jalal al-Din al-Suyuti, wrote a book on the subject which has been translated into English by Sidi Talut Dawood. It is excerpted below:

“Ibn ‘Adi has narrated from Abu Hurayrah (r) 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 (r) 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. All the Sultan’s Men, English translation of ما رواه الأساطين في عدم المجئ إلى السلاطين by Talut Dawood, Imam Ghazali Institute, 2021, pp. 32-33]