First Law Codes
Although the Babylonian monarch Hammurabi's (r. 1792-1750 BCE) legal code is well-known, it was not the first law code in the world, or even in Mesopotamia. The Code of Urukagina was written in the 24th century BCE, and the Code of Ur-Nammu (r. 2047-2030 BCE), founder of the Third Dynasty of Ur in Sumer, was written in the Ur III Period (2047-1750 BCE). It's possible that Ur-code Nammu's was authored by his son and successor, Shulgi of Ur (r. 2029-1982 BCE), but if so, it was either based on or constructed in accordance with his father's teachings.
The Code of Ur-Nammu, one of the interesting facts about the ancient Mesopotamian civilization, influenced the later Code of Hammurabi by clarifying the penalties for transgressions and legitimizing itself as a divinely inspired document. Because he reigned over a more diverse people that did not share the same theological image of the gods and their dispensation of justice, Hammurabi's Code had to be tougher.