Al-Sha'bi (may Allah have mercy on him) said: When Umar bin al-Khattab (may Allah be pleased with him) appointed Shurayh (may Allah have mercy on him) as judge of Kufa, he advised him: Whatever issue is clear to you from the Book of Allah, do not seek anyone's counsel about it; whatever is not clear from the Book of Allah, follow the Sunnah in it; and whatever is not clear in the Sunnah, exercise your own judgement (ijtihad) in it.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب آداب القاضي / 20312