And whoever said that the Imam has the choice in judging between them (the People of the Book), and that if he judges, he judges by what Allah, the Mighty and Majestic, has revealed; and whoever said that it is obligatory upon him to judge between them and he has no choice (not to judge).
Imam al-Shafi'i (may Allah have mercy on him) said: "Allah, the Mighty and Majestic, said to His Prophet (peace and blessings be upon him) concerning the People of the Book: 'So if they come to you, judge between them or turn away from them.' [Surah al-Ma'idah: 42] So in this verse, and Allah knows best, there is a clarification that Allah Almighty gave His Prophet (peace and blessings be upon him) the choice to judge between them or to turn away from them, and made it binding upon him (peace and blessings be upon him) that if he judges, he judges between them with justice."
He (further) said: "And I heard one of the people of knowledge with whom I am satisfied say, concerning the saying of Allah, the Mighty and Majestic, 'And judge between them by what Allah has revealed' [Surah al-Ma'idah: 49]: (it means) if you judge, (then judge by it); it is not a binding command that you (must) judge."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الحدود / Q17114