Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) said: "O people, a time has passed over us when we did not give judgements, nor were we in that position, and (now) Allah has brought us to the state that you see. So whoever of you has to give a judgement after today, let him judge in it according to the Book of Allah. If a matter comes to him that is not in the Book of Allah, let him judge according to what the Messenger of Allah (peace and blessings be upon him) judged. If a matter comes to him that is neither in the Book of Allah nor has the Messenger of Allah (peace and blessings be upon him) judged on it, let him judge according to what the righteous judged. And if a matter comes to him that is neither in the Book of Allah, nor has the Messenger of Allah (peace and blessings be upon him) judged on it, nor have the righteous judged on it, let him exercise his own reasoning (ijtihad). And let none of you say: 'I am afraid,' or 'My opinion is,' for the lawful is clear and the unlawful is clear, and between them are doubtful matters. So leave what makes you doubt for what does not make you doubt."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 8888