Narrated Amr bin Al-Aas: That he heard the Prophet, peace be upon him, saying, “If a judge gives a verdict [religious ruling] according to the best of his knowledge and his verdict is correct, he will receive a double reward.
If he gives a verdict according to the best of his knowledge and his verdict is wrong (i.e. against that of Allah & His Messenger) even then he will get a reward.”
[9: 450- O.B. Sahih Al-Bukhari)