Sayyidina Mu’adh (RA) reported that (when) Allah’s Messenger sent him to Yarnan, he asked him how he would decide (cases). He said, “I will decide in accordance with Allahs Book (the Qur’an).” He asked, “What, if it is not in the Book of Allah?” He said, “Then according to the sunnah of Allah’s Messenger ----: .“ He asked, “And if it is not in the sunnah of Allah’s Messenger?” He said, “I will make ijtihad0 through my judgemenet.” The Prophet - said, “Praise belongs to Allah Who has made the messenger of the Messenger of Allah consistent with what pleases him.”
[Abu Dawud 3592, Ahmed 22161]