Some 20 years after Emperor Wuzong's death, the Tang empire began its last phase of collapse. The source of the downfall can be traced to an event in 868 when a group of soldiers in Gui Prefecture (Guangxi) under Pang Xun rebelled after the government ordered them to extend their garrison duty for one extra year, even though they had already served six years on what was supposed to be a three-year assignment. The rebellion spread northwards to the Chang Jiang and Huai River before its suppression in 869 by Shatuo cavalry under the command of Li Guochang. While the Tang court was still smarting from the impact of the Pang Xun rebellion, in 874, a salt trader by the name of Wang Xianzhi stirred up another rebellion in Changyuan, Puzhou, Henan. In 875 Wang was joined by Huang Chao, who eventually took over leadership of the rebel army when Wang died in 878. The cataclysmic Huang Chao rebellion was one of such vast magnitude that it shook the very foundations of the Tang empire, destroying it both internally as well as cutting off any pre-existing foreign contacts it had with the outside world. At the rebellion's peak, Huang claimed to command an army of one million. It swept through much of the lower and middle Yangzi valleys, devastated the Central Plains, and went as far south as Guangzhou (879). After sacking the twin capitals Luoyang in 880 and Chang'an the following year, Huang Chao declared the founding of his Great Qí (大齊) dynasty.
