They were, however, defeated by the general Li Maozhen and captured while in flight; they were then delivered to the capital Chang'an and executed.
Yang Fugong was literate and well-learned, and subsequently successively served as a eunuch monitor for several imperial armies.
During the Pang Xun rebellion of 868–869, Yang Fugong served as the eunuch monitor of the Heyang Circuit (河陽, headquartered in modern JIaozuo, Henan), and after Pang's rebellion was suppressed, Yang was credited and recalled to the capital Chang'an to serve as the palace-government liaison (宣徽使, Xuanhuishi).
Yang Fugong thus claimed to be ill and retired to his own mansion in Lantian (藍田, in modern Xi'an, Shaanxi).
[3] In 885, by which time Huang's rebellion had been suppressed and Emperor Xizong had returned to Chang'an, Tian provoked the warlord Wang Chongrong (the military governor of Hezhong Circuit (河中, headquartered in modern Yuncheng, Shanxi)) by ordering Wang's transfer.
Wang reacted by aligning himself with Li Keyong the military governor of Hedong Circuit (河東, headquartered in modern Taiyuan, Shanxi), and Wang and Li Keyong's troops defeated those of Tian and Tian's allies Li Changfu the military governor of Fengxiang Circuit (鳳翔, headquartered in modern Baoji, Shaanxi) and Zhu Mei the military governor of Jingnan Circuit (靜難, headquartered in modern Xianyang, Shaanxi).
Tian again took Emperor Xizong and fled Chang'an, to Xingyuan (興元, in modern Hanzhong, Shaanxi).
It was during this flight that Emperor Xizong made Yang Fugong the director of palace communications again, and soon thereafter, when Tian realized that he was open to condemnation from all sides (with his allies Li Changfu and Zhu having abandoned him, and Zhu going as far as supporting Emperor Xizong's distant relative Li Yun the Prince of Xiang as an alternative claimant to the imperial throne), Tian recommended Yang Fugong to succeed him, while making himself the eunuch monitor of Xichuan so that he could join his brother Chen.
Li Yun fled to Hezhong and was killed by Wang Chongrong, and his competing claim was extinguished.
[5] Upon Emperor Xizong's return to Chang'an, for Yang Fugong's contributions, he was created the Duke of Wei.
He further offended the emperor by being arrogant, including riding a litter all the way into the palace, and adopting many strong military officers to be his sons.
Yang Fugong also developed another enmity, with Emperor Zhaozong's maternal uncle Wang Gui (王瓌).
However, in spring 892, five nearby military governors—Li Maozhen of Fengxiang, Wang Xingyu of Jingnan, Han Jian of Zhenguo Circuit (鎮國, headquartered in modern Weinan, Shaanxi), Wang Xingyue (王行約, Wang Xingyu's brother) of Kuangguo Circuit (匡國, headquartered in modern Weinan as well), and Li Maozhuang (李茂莊, Li Maozhen's brother) of Tianxiong (天雄, headquartered in modern Tianshui, Gansu)—apparently seeing this as an excellent opportunity to annex the Yangs' territory, submitted a joint petition requesting permission to attack the Yangs and requesting that Li Maozhen be put in command of the operations.