By the end of the 4th century, the region between the Yangtze and the Gobi, including much of modern Xinjiang, was dominated by the Tuoba. Emerging as the partially sinicized state of Dai between AD 338 and 376 in the Shanxi area, the Tuoba established control over the region as the Northern Wei (AD 386-533). Northern Wei armies drove back the Rouran (also referred to as Ruru or Juan-Juan by Chinese chroniclers), a newly arising nomadic Mongol people in the steppes north of the Altai Mountains, and reconstructed the Great Wall. During the 4th century also, the Huns left the steppes north of the Aral Sea to invade Europe. By the middle of the 5th century, Northern Wei had penetrated into the Tarim Basin in Inner Asia, as had the Chinese in the 2nd century. As the empire grew, however, Tuoba tribal customs were supplanted by those of the Chinese, an evolution not accepted by all Tuoba. Tuoba Wei existed until 581. A branch of the Xianbei, the Rouran (also known as Nirun) were consolidated under Mugulyu. In the late 5th century, the Rouran established a powerful nomadic empire spreading generally farther north of Northern Wei. It was probably the Rouran who first used the title khan. The Rouran ruled Mongolia, eastern Kazakhstan, part of Gansu, northern Xinjiang, Inner Mongolia, parts of Northeastern China and southern Siberia. The Hephthalite Empire was a vassal state to the Rouran for 100 years. Shelun assumed the title of "Khagan" in 402 landmarking the establishment of the state of the Rouran Khaganate. The Tuoba waged long wars against the Rouran Khaganate. The Altai Turkics that were subjects of the Rouran revolted in 552 establishing the Turkic Khaganate. The Rouran Khaganate was finally defeated by the Turkics in 555. Part of the Rouran left the present territory of Mongolia. A number of historians maintain that they established the Avarian Kaganate between the river Danube and the Carpathian Mountains. The Rourans that stayed in Mongolia became the ancestors of the Tatar tribes. The Tatars and other Mongol tribes lived in the eastern part Mongolia during the Turkic period. Other Mongols that migrated east returned in the 8th century.