Finally in AD 439 Tuobadao, emperor of the Northern Wei unified Northern China under his rule. This was the beginning of the Northern Dynasty and marked the first time the Mongolians took over China.In these confusing times, the country became sharply divided. In AD 543 Prime Minister of the Northern Wei, Gao Huan, established the Eastern Wei (AD 534-550) at Luoyang, while another general, Yu Wen Tai established the Western Wei (AD 535-556) at Xian. Finally in AD 549 Gao Yang conquered the Eastern Wei and formed the Northern Qi (AD549-577), as a Mongolian state.
Meanwhile, Yu Wen Jue took over the Western Wei to establish the Northern Zhou (AD557-581), following the Han manner of rule. The country was only unified under the Sui dynasty under Emperor Sui Wen in AD 581.