Al-Harith bin Amr narrates from the companions of Sayyiduna Mu'adh (may Allah be pleased with him), from Sayyiduna Mu'adh (may Allah be pleased with him), that when the Prophet (peace and blessings be upon him) sent Sayyiduna Mu'adh (may Allah be pleased with him) to Yemen, he said: "How will you judge when a case comes before you?" He said: By the Book of Allah. He (peace and blessings be upon him) said: "And if you do not find it in the Book of Allah?" He said: In accordance with the Sunnah of the Messenger of Allah (peace and blessings be upon him). He (peace and blessings be upon him) said: "And if you do not find it in the Sunnah of the Messenger of Allah (peace and blessings be upon him)?" He said: By my own opinion, and I will spare no effort. He said: The Prophet (peace and blessings be upon him) passed his hand over my chest and said: "All praise is for Allah, who has enabled the envoy of the Messenger of Allah (peace and blessings be upon him) to do what pleases the Messenger of Allah (peace and blessings be upon him)."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب آداب القاضي / 20339