At the end of the third millennium BCE, the city-state of Ur presided over most of Mesopotamia. Apart from the capital, there were important subsidiary centres at Sippar, Nippur and Isin. After the death of the ruler, Shulgi, early in the second millennium BCE, Ur fell into decline, and was sacked by the neighbouring Elamites in c. 2004 BCE. The Elamites were soon driven out by the ruler of Isin, but the resurgence was brief. Ur would never recover its influence in Upper Mesopotamia, and repeatedly fell under the control of neighbouring cities, Larsa and Lagash. To the north of Mesopotamia, an arc of city states stretched to the Mediterranean, where Ugarit was an important trading centre, noted in contemporary Egyptian records. In Egypt, Mentuhotep II of the 11th Dynasty achieved reunification (2022 BCE), paving the way for the military expansion and cultural flowering of the 12th Dynasty.