Located on the Euphrates River. Hammurabi developed a code of laws used to unify his empire, it was a total of 282 laws.Hammurabi was a First Dynasty king of the city-state of Babylon, and inherited the power from his father, Sin-Muballit, in c. 1792 BC. Babylon was one of the many ancient city-states that dotted the Mesopotamian plain and waged war on each other for control of fertile agricultural land. Though many cultures co-existed in Mesopotamia, Babylonian culture gained a degree of prominence among the literate classes throughout the Middle EastThe kings who came before Hammurabi had begun to consolidate rule of central Mesopotamia under Babylonian hegemony and, by the time of his reign, had conquered the city-states of Borsippa, Kish, and Sippar. Thus Hammurabi ascended to the throne as the king of a minor kingdom in the midst of a complex geopolitical situation. The powerful kingdom of Eshnunna controlled the upper Tigris River while Larsa controlled the river delta. To the east lay the kingdom of Elam. To the north, Shamshi-Adad I was undertaking expansionistic wars, although his untimely death would fragment his newly conquered Semitic empire.
The first few decades of Hammurabi's reign were quite peaceful. Hammurabi used his power to undertake a series of public works, including heightening the city walls for defensive purposes, and expanding the temples. In c. 1801 BC, the powerful kingdom of Elam, which straddled important trade routes across the Zagros Mountains, invaded the Mesopotamian plain. With allies among the plain states, Elam attacked and destroyed the empire of Eshnunna, destroying a number of cities and imposing its rule on portions of the plain for the first time. In order to consolidate its position, Elam tried to start a war between Hammurabi's Babylonian kingdom and the kingdom ofLarsa. Hammurabi and the king of Larsa made an alliance when they discovered this duplicity and were able to crush the Elamites, although Larsa did not contribute greatly to the military effort. Angered by Larsa's failure to come to his aid, Hammurabi turned on that southern power, thus gaining control of the entirety of the lower Mesopotamian plain by c. 1763 BC.
As Hammurabi was assisted during the war in the south by his allies from the north, the absence of soldiers in the north led to unrest. Continuing his expansion, Hammurabi turned his attention northward, quelling the unrest and soon after crushing Eshnunna. Next the Babylonian armies conquered the remaining northern states, including Babylon's former ally Mari, although it is possible that the 'conquest' of Mari was a surrender without any actual conflict. In just a few years, Hammurabi had succeeded in uniting all of Mesopotamia under his rule. Of the major city-states in the region, only Aleppo and Qatna to the west in Syria maintained their independence. However, one stele of Hammurabi has been found as far north as Diyarbekir, where he claims the title "King of the Amorites".