It was not until nearly a generation had passed, after Rîm-Sin's capture of Nîsin, that Hammurabi made any headway against the Elamite domination, which for so long had arrested any increase in the power of Babylon.[91] But his success, when it came, was complete and enduring. In his thirtieth year he records that he defeated the army of Elam, and in the next campaign he followed up this victory by invading the land of Emutbal, inflicting a final defeat on the Elamites, and capturing and annexing Larsa. Rîm-Sin himself appears to have survived for many years, and to have given further trouble to Babylon in the reign of Hammurabi's son, Samsu-iluna.--And the evidence seems to show that for a few years at least he was accorded the position of vassal ruler at Larsa.[92] On this supposition Hammurabi, after his conquest of Sumer, would have treated the old capital in the same way that Sumu-abum treated Kish.[93] But it would seem that after a time Larsa must have been deprived of many of its privileges, including that of continuing its own era of time-reckoning; and Hammurabi's letters to Sin-idinnam, his local representative, give no hint of any divided rule. We may perhaps assume that Rîm-Sin's subsequent revolt was due to resentment at this treatment, and that in Samsu-iluna's reign he seized a favourable opportunity to make one more bid for independent rule in Babylonia.
The defeat of Rîm-Sin, and the annexation of Sumer to Babylon, freed Hammurabi for the task of extending his empire on its other three sides. During these later years he twice made successful raids in the Elamite country of Tupliash or Ashnunnak, and on the west he destroyed the walls of Mari and Malgûm, defeated the armies of Turukkum, Kagmum and Subartu, and in his thirty-ninth year he records that he destroyed all his enemies that dwelt beside Subartu. It is probable that he includes Assyria under the geographical term Subartu, for both Ashur and Nineveh were subject to his rule; and one of his letters proves that his occupation of Assyria was of a permanent character, and that his authority was maintained by garrisons of Babylonian troops. Hammurabi tells us too, in the Prologue to his Code of Laws, that he subjugated "the settlements on the Euphrates," implying the conquest of such local West-Semitic kingdoms as that of Khana.[94] On the west we may therefore regard the area of his military activities as extending to the borders of Syria. Up to the close of his reign he continued to improve the defences of his country, for he devoted his last two years to rebuilding the great fortification of Kâr-Shamash on the Tigris and the wall of Rabikum on the Euphrates, and he once again strengthened the city-wall of Sippar. His building-inscriptions also bear witness to his increased activity in the reconstruction of temples during his closing years.[95]