Hadithcore
Mishkat al-Masabih, 3741

'Abdallah b. Abu Aufa reported God’s Messenger as saying, “God is with the <i>qadi</i> as long as he is not tyrannical, but when he is He departs from him and the devil attaches himself to him.” A version has, “When he is tyrannical He leaves him to his own devices.” Tirmidhi and Ibn Majah transmitted it.

وَعَنْ عَبْدُ اللَّهِ بْنِ أَبِي أَوْفَى قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «إِنَّ اللَّهَ مَعَ الْقَاضِي مَا لَمْ يَجُرْ فَإِذَا جَارَ تَخَلَّى عَنْهُ وَلَزِمَهُ الشَّيْطَانُ» . رَوَاهُ التِّرْمِذِيُّ وَابْنُ مَاجَهْ وَفِي رِوَايَةٍ: «فَإِذَا جارَ وَكله إِلَى نَفسه»

References1 variant
In-Book Reference
Book 18, Hadith 80