Sayyiduna Abu Juhayfah (may Allah be pleased with him) narrates from Sayyiduna Ali (may Allah be pleased with him) that he said: "The Messenger of Allah (peace and blessings be upon him) sent me to the people of Yemen, so I said: 'O Messenger of Allah (peace and blessings be upon him)! You are sending me to a people while I have no knowledge of judging (between people).' Then he (peace and blessings be upon him) placed his hand on my chest and said: 'Indeed Allah, the Mighty and Majestic, will guide your heart and keep your tongue firm. So when two disputing parties sit before you, do not judge in favour of the first until you have heard the other just as you heard the first, for that is more likely to make the judgement clear to you.'"
Sayyiduna Ali (may Allah be pleased with him) said: "After that I remained a judge continuously," or he said: "After that I never had a doubt about any judgement."