stylistic:style_transfer
The Jin dynasty or Jin Empire, sometimes distinguished as the Sima Jin or the Two Jins, was an imperial dynasty in China that existed from 266 to 420. It was founded by Sima Yan, eldest son of Sima Zhao, who had previously been declared the King of Jin. There are two main divisions in the history of the dynasty. The Western Jin (266–316) was established as the successor to Cao Wei after Sima Yan usurped the throne from Cao Huan and took the title of Emperor Wu. The capital of the Western Jin was initially in Luoyang, though it later moved to Chang'an (modern Xi'an). In 280, after conquering Eastern Wu, the Western Jin ended the Three Kingdoms period and reunited China proper for the first time since the end of the Han dynasty.

From 291 to 306, a series of civil wars known as the War of the Eight Princes were fought over control of the Jin state which weakened it considerably. In 304, the dynasty experienced a wave of rebellions by non- Han ethnicities termed the Five Barbarians, who went on to establish several short-lived dynastic states in northern China. This inaugurated the chaotic and bloody Sixteen Kingdoms era of Chinese history, in which states in the north rose and fell in rapid succession, constantly fighting both one another and the Jin. Han-Zhao, one of the northern states established during the disorder, sacked Luoyang in 311, captured Chang'an in 316, and executed Emperor Min of Jin in 318, ending the Western Jin era. Sima Rui, who succeeded Emperor Min, then reestablished the Jin dynasty with its capital in Jiankang (modern Nanjing), inaugurating the Eastern Jin (317–420).

The Eastern Jin dynasty remained in near-constant conflict with its northern neighbors for most of its existence, and it launched several invasions of the north with the aim of recovering its lost territories. In 383, the Eastern Jin inflicted a devastating defeat on the Former Qin, a Di -ruled state that had briefly unified northern China. In the aftermath of that battle, the Former Qin state splintered, and Jin armies recaptured the lands south of the Yellow River. The Eastern Jin was eventually usurped by General Liu Yu in 420 replaced with the Liu Song dynasty. The Eastern Jin dynasty is considered the second of the Six Dynasties.