Wa `alaykum as-salamu wa rahmatullahi wa barakatuh.
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
Brother, we really appreciate your question, and we commend your keenness on getting yourself well-acquainted with the teachings of Islam. May Allah help us all keep firm on the Right Path.
It goes without saying that the basic spirit of any law is to establish justice among people. There is nothing wrong, as far as the Islamic Shari`ah is concerned, for a Muslim to work as a judge in a secular country and to judge according to secular law as long as he will strive to achieve justice and fairness among the disputing parties, Muslims or non-Muslims.
In his response to your question, Sheikh Muhammad Al-Mukhtar Ash-Shinqiti, Professor of Political Ethics and Religions History at Qatar University, states:
Every law, be it religious or secular, is meant to establish justice. Therefore, a Muslim is allowed to work as a judge, as long as he will strive to achieve justice and apply fairness in settling between the disputing parties. It is true that he will be forced to work within the limitations of the legal system the country is subject to, but to have a fair judge is better than leaving the corrupt to take over.
Having said this, there can never be any similarity between the law revealed by God and man-made legislations. What is meant here is that justice is to be achieved at any cost, even by committing the lesser of two evils or choosing the “good bad.”
Moreover, Sheikh Ahmad Kutty, a senior lecturer and Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, adds:
I don’t see any objection for a Muslim to serve as a judge as long as he does not explicitly contradict the categorically established principles of the Shari`ah. It is my understanding that the basic spirit of law is to establish justice; this is a clear Qur’anic imperative.
It is also known from the principles of Islam that we are allowed to act as arbitrators based on principles and criteria agreed upon. A judge in a secular system is doing so in accordance with such criteria that are acceptable to all parties, including Muslims and non-Muslims.
Allah Almighty knows best.