As far as I can tell, the first Judicial system is established in Torah Parsh Yitro. Before this time, justice was decided by kings and priests. The Hammurabi code is contemporary and similar in concept as it sets a standard in place in writing. This is topic for another time.
In Parsha Yitro, we see Moses being judge and teacher for the entire nation, and completely overburdened by the task. His father-in-law, Yitro, the Midianite priest, gives counsel to set up a judicial system. Moses does this immediately.
Next, the Judiciary needs a code, a body of law, to judge fairly. The foundation of Law comes from G~d at Sinai soon after the judiciary is established. Further refinements follow through the balance of Torah. This body of Torah law is the basis and foundation of the legal codes in much of the world today.
This artistic rendition of Sinai is at
Here are some study notes: