The Prophet (ﷺ) as saying: "Judges are of three types, one of who will go to Paradise and two to Hell. The one who will go to Paradise is a man who knows what is right and gives judgement accordingly; by a man who knows what is right and acts tyrannically in his judgement will go to Hell; and a man who gives judgement for people when he is ignorant will go to Hell."
Abu Dawud said: On this subject this is the soundest tradition, that is m the tradition of Ibn Buraidah: Judges are of three types.