فَفَهَّمْنَاهَا سُلَيْمَانَ وَكُلًّ اتَيْنَا حُكْمًا وَعِلْمًا
And We made Suleiman to understand (the case); and to each of them We gave wisdom and knowledge.
Ibn Abi Hatim recorded that;
when Iyas bin Mu`awiyah was appointed as a judge, Al-Hasan came to him and found Iyas weeping. (Al-Hasan) said, "Why are you weeping?"
(Iyas) said, "O Abu Sa`id, What I heard about judges among them a judge is he, who studies a case and his judgment is wrong, so he will go to Hell; another judge is he who is biased because of his own whims and desires, so he will go to Hell; and the other judge he who studies a case and gives the right judgement, so he will go to Paradise."
Al-Hasan Al-Basari said;"But what Allah tells us about Dawud and Suleiman (peace be upon them both) and the Prophets and whatever judgments they made proves that what these people said is wrong.
Allah says;
وَدَاوُودَ وَسُلَيْمَانَ إِذْ يَحْكُمَانِ فِي الْحَرْثِ إِذْ نَفَشَتْ فِيهِ غَنَمُ الْقَوْمِ وَكُنَّا لِحُكْمِهِمْ شَاهِدِينَ
And (remember) Dawud and Suleiman, when they gave judgement in the case of the field in which the sheep of certain people had pastured at night; and We were witness to their judgement.
Allah praised Suleiman but He did not condemn Dawud."
Then he -- Al-Hasan -- said, "Allah enjoins three things upon the judges;
not to sell thereby for some miserable price;
not to follow their own whims and desires; and
not to fear anyone concerning their judgments."
Then he recited;
يدَاوُودُ إِنَّا جَعَلْنَـكَ خَلِيفَةً فِى الاٌّرْضِ فَاحْكُمْ بَيْنَ النَّاسِ بِالْحَقِّ وَلَا تَتَّبِعِ الْهَوَى فَيُضِلَّكَ عَن سَبِيلِ اللَّهِ
O Dawud! Verily, We have placed you as a successor on the earth; so judge you between men in truth and follow not your desire -- for it will mislead you from the path of Allah. (38;26)
فَلَ تَخْشَوُاْ النَّاسَ وَاخْشَوْنِ
Therefore fear not men but fear Me. (5;44)
وَلَا تَشْتَرُواْ بِـَايَـتِى ثَمَناً قَلِيلً
and sell not My Ayat for a miserable price. (5;44)
I say;with regard to the Prophets (peace be upon them all), all of them were infallible and supported by Allah. With regard to others, it is recorded in Sahih Al-Bukhari from `Amir bin Al-`As that the Messenger of Allah said;
إِذَا اجْتَهَدَ الْحَاكِمُ فَأَصَابَ فَلَهُ أَجْرَانِ
وَإِذَا اجْتَهَدَ فَأَخْطَأَ فَلَهُ أَجْر
If the judge does his best, studies the case and reaches the right conclusion, he will have two rewards.
If he does his best, studies the case and reaches the wrong conclusion, he will have one reward.
This Hadith refutes the idea of Iyas, who thought that if he did his best, studied the case and reached the wrong conclusion, he would go to Hell.
And Allah knows best.
Similar to story in the Qur'an is the report recorded by Imam Ahmad in his Musnad from Abu Hurayrah, who said that the Messenger of Allah said;
بَيْنَمَا امْرَأَتَانِ مَعَهُمَا ابْنَانِ لَهُمَا إِذْ جَاءَ الذِّيْبُ فَأَخَذَ أَحَدَ الاْبْنَيْنِ فَتَحَاكَمَتَا إِلَىىَداوُدَ فَقَضَى بِهِ لِلْكُبْرَى فَخَرَجَتَا فَدَعَاهُمَا سُلَيْمَانُ فَقَالَ هَاتُوا السِّكِّينَ أَشُقُّهُ بَيْنَكُمَا فَقَالَتِ الصُّغْرَى يَرْحَمُكَ اللهُ هُوَ ابْنُهَا لَا تَشُقَّهُ فَقَضَى بِهِ لِلصُّغْرَى
There were two women who each had a son. The wolf came and took one of the children, and they referred their dispute to Dawud. He ruled that the (remaining) child belonged to the older woman. They left, then Suleiman called them and said, "Give me a sword and I will divide him between the two of you."
The younger woman said, "May Allah have mercy on you! He is her child, do not cut him up!"
So he ruled that the child belonged to the younger woman.
This was also recorded by Al-Bukhari and Muslim in their Sahihs.
An-Nasa'i also devoted a chapter to this in the Book of Judgments.
وَسَخَّرْنَا مَعَ دَاوُودَ الْجِبَالَ يُسَبِّحْنَ وَالطَّيْرَ
And We subjected the mountains and the birds to glorify Our praises along with Dawud.
This refers to the beauty of his voice when he recited his Book, Az-Zabur. When he recited it in a beautiful manner, the birds would stop and hover in the air, and would repeat after him, and the mountains would respond and echo his words.
وَكُنَّا فَاعِلِينَ
And it was We Who were the doer (of all these things).
The Prophet passed by Abu Musa Al-Ash`ari while he was reciting Qur'an at night, and he had a very beautiful voice, he stopped and listened to his recitation, and said;
لَقَدْ أُوتِيَ هَذَا مِزْمَارًا مِنْ مَزَامِيرِ الِ دَاوُد
This man has been given one of the wind instruments (nice voices) of the family of Dawud.
He said;"O Messenger of Allah, if I had known that you were listening, I would have done my best for you."