section_path: History/End of the dynasty
section_name: End of the dynasty
paragraph_text: End of the dynasty
  
  In addition to natural calamities and jiedushi amassing autonomous control, the Huang Chao Rebellion (874–884) resulted in the sacking of both Chang'an and Luoyang, and took an entire decade to suppress. It was the Huang Chao rebellion by the native Han rebel Huang Chao that permanently destroyed the power of the Tang dynasty since Huang Chao not only devastated the north but marched into southern China (which An Lushan failed to do due to the Battle of Suiyang). Huang Chao's army in southern China committed the Guangzhou massacre against foreign Arab and Persian Muslim, Zoroastrian, Jewish and Christian merchants in 878–879 at the seaport and trading port of Guangzhou, and captured both Tang dynasty capitals, Luoyang and Chang'an. A medieval Chinese source claimed that Huang Chao killed 8 million people. The Tang never recovered from this rebellion, weakening it for future military powers to replace it. Large groups of bandits in the size of small armies ravaged the countryside in the last years of the Tang. They smuggled illicit salt, ambushed merchants and convoys, and even besieged several walled cities. Amid the sacking of cities and murderous factional strife among eunuchs and officials, the top tier of aristocratic families, which had amassed a large fraction of the landed wealth and official positions, was largely destroyed or marginalized.
  
  During the last two decades of the Tang dynasty, the gradual collapse of central authority led to the rise of two prominent rival military figures over northern China: Li Keyong and Zhu Wen. Tang forces had defeated Huang Chao's rebellion with the crucial aid of allied Shatuo, a Turkic people of what is now Shanxi, led by Li Keyong. He was made a jiedushi, and later Prince of Jin, bestowed with the imperial surname Li by the Tang court. Zhu Wen, originally a salt smuggler who served as a lieutenant under the rebel Huang Chao, surrendered to Tang forces. By helping to defeat Huang, he was renamed Zhu Quanzhong ("Zhu of Perfect Loyalty") and granted a series of rapid military promotions to military governor of Xuanwu Circuit.
  
  In 901, from his power base of Kaifeng, Zhu Wen seized control of the Tang capital Chang'an and with it the imperial family. By 903 he forced Emperor Zhaozong of Tang to move the capital to Luoyang, preparing to take the throne for himself. In 904 Zhu assassinated Emperor Zhaozong to replace him with the emperor's young son Emperor Ai of Tang. In 905 Zhu executed the brothers of Emperor Ai as well as many officials and Empress Dowager He. In 907 the Tang dynasty was ended when Zhu deposed Ai and took the throne for himself (known posthumously as Emperor Taizu of Later Liang). He established the Later Liang, which inaugurated the Five Dynasties and Ten Kingdoms period. A year later Zhu had the deposed Emperor Ai poisoned to death.
  
  Zhu Wen's hated nemesis Li Keyong died in 908 but, out of loyalty to Tang, Li never claimed the title of emperor. His son Li Cunxu (Emperor Zhuangzong) inherited his title Prince of Jin along with his father's rivalry against Zhu. In 923 Li Cunxu declared a "restored" Tang dynasty, the Later Tang, before toppling the Later Liang dynasty the same year. However, southern China would remain splintered into various small kingdoms until most of China was reunified under the Song dynasty (960–1279). Control over parts of northeast China and Manchuria by the Liao dynasty of the Khitan people also stemmed from this period. In 905 their leader Abaoji formed a military alliance with Li Keyong against Zhu Wen but the Khitans eventually turned against the Later Tang, helping another Shatuo leader Shi Jingtang of Later Jin to overthrow Later Tang in 936.