Allah, exalted be His praise, says: "Indeed, Allah commands you to render trusts to those to whom they are due, and when you judge between people, to judge with justice." [Surah al-Nisa: 58]
And He said to His Prophet (peace and blessings be upon him): "And that you judge between them by what Allah has revealed, and do not follow their desires." [Surah al-Ma'idah: 49]
And the Messenger of Allah (peace and blessings be upon him) sent out governors (officials) and judges, and likewise the Caliphs after him did (the same), and it is they who are followed in the Shari'ah. Success and protection come only from Allah.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب النذور / Q20149