Answer:
Satan is necessarily with a judge who commits injustice. It is narrated from Sayyidna Abdullah ibn Abi Awfa (may Allah be pleased with him) that the Messenger of Allah ﷺ said:
إن الله مع القاضي ما لم يجر، فإذا جار تخلى عنه ولزمه الشيطان
“Indeed, Allah the Exalted is with the judge as long as he does not commit injustice. Then when he commits injustice, Allah withdraws from him and Satan clings to him.”
The reason for this is that transgression is a branch of injustice, and injustice is a major branch among the branches of sins. Committing acts of disobedience is among the things Satan loves. Every companion joins his own like, whereas Allah the Exalted commands us to act with justice, as He said:
وَلَا يَجْرِمَنَّكُمْ شَنَآنُ قَوْمٍ عَلَىٰ أَلَّا تَعْدِلُوا ۚ اعْدِلُوا هُوَ أَقْرَبُ لِلتَّقْوَىٰ ۖ
“And let not the hatred of a people make you wrong in justice so that you do not act justly. Act justly; that is closer to piety.”