 He thus joined the Zhongwu Circuit army and became an officer under then-military governor ("Jiedushi") Du Shenquan.As of 881, the major agrarian rebel Huang Chao had captured the Tang capital Chang'an, forcing then-reigning Emperor Xizong to flee to Chengdu.Zhongwu's then-military governor Zhou Ji initially submitted to Huang, who established a new state of Qi as its emperor, but at the urging by the eunuch general Yang Fuguang redeclared allegiance to Tang in summer 881.