The Upheaval of the Five Barbarians also translated as the Rebellion, the Revolt, or the Invasion of the Five Barbarians () is a Chinese expression which refers to a series of rebellions and invasions between 304 and 316 by non-Han peoples, commonly called the Five Barbarians, living in North China against the Jin Empire, which had recently been weakened by a series of civil wars. The uprisings helped topple Emperor Huai of Jin in Luoyang and they ended the Western Jin dynasty in northern China. Rulers from four ethnic groups, the Xiongnu, Jie, Qiang and Di, then established a series of independent dynastic realms in northern China. The fifth group, the Xianbei in the north, were allied to the Western Jin and later Eastern Jin against the other four barbarians until turning on the Jin much later. A series of revolts in southern China occurred at the same time by refugees in Sichuan, Hubei and Hunan, resulting in the establishment of the Ba-Di Cheng Han state in Sichuan. This chaotic period of Chinese history, known as the Sixteen Kingdoms (五胡十六國, "Sixteen States of the Five Barbarians"), lasted over 130 years until the Northern Wei dynasty united northern China in the 5th century. The Eastern Jin dynasty survived in southern China until its eventual replacement by the Liu Song dynasty in 420. Background The southward migration of nomadic tribes into the lands around the Yellow River had been ongoing since the Eastern Han dynasty for several reasons. The Han dynasty's defeat of the Xiongnu confederation in the Han–Xiongnu War by Han General Dou Xian led to the Han dynasty deporting the Southern Xiongnu along with their Chanyu into northern China. In 167 AD, Duan Jiong conducted an anti-Qiang campaign and massacred Qiang populations as well as settled them outside the frontier in northern China. The wars of the later Three Kingdoms period also encouraged this immigration, which repopulated previously devastated areas and provided military power and labour. By the end of the 4th century, the nomadic tribes had moved into the Guanzhong area, as well as the watersheds of the Wei and Xing rivers, practically surrounding the Jin capital in Luoyang. At the same time, the accession of Emperor Hui of Jin, who was possibly developmentally disabled, led to a struggle between the princes of the ruling Sima family to control him, sparking off the War of the Eight Princes. Revolts