Through his chain of transmission, it is reported from ʿAbd al-Raḥmān ibn Samurah that the Prophet ﷺ said to him: “O Abu ʿAbd al-Raḥmān, do not ask for authority. For if you are given it without asking for it, you will be aided in it.”
Muslim records in his Ṣaḥīḥ, through his chain of transmission from Abu Burdah ibn Abu Musa, from his father Abu Musa al-Ashʿari, who said: “I entered upon the Prophet ﷺ with two men from my paternal cousins. One of the two said to the Messenger of Allah ﷺ, ‘Appoint us over some of the authority that Allah has entrusted to you.’ The other said the same. He replied, ‘By Allah, we do not appoint to this office anyone who asks for it.’ Thus, he appointed neither of them.”
The second report is that it is not disliked. The basis for this is something he said, as reported in the narration of al-Marwazī: “The Muslims must have a ruler; otherwise, would people’s rights be lost?” The rationale is that this constitutes the removal of a wrong. According to this report, the matter must be examined. If his primary intention in seeking the office is to remove an unqualified person from it, he is rewarded. But if his primary intention is to secure the exclusive right to exercise judicial authority, then seeking it is either disliked or permissible.
If the office of judge is already held by someone deserving of it—someone qualified to serve in it—and he seeks to remove him, either because of enmity between them or in order to derive some personal benefit from the judicial office, then seeking it is prohibited, and he is thereby discredited.
If no one is serving as judge, the matter must be examined. If he desires to uphold justice and fears that someone unqualified will undertake the office, then the matter is governed by the two reports mentioned above.