governor of Jingnan Circuit (靜難, headquartered in modern Xianyang, Shaanxi) and Li Changfu the military governor of Fengxiang Circuit (鳳翔, headquartered in modern Baoji, Shaanxi). Wang Chongrong's and Li Keyong's forces defeated Tian's, Zhu's, and Li Changfu's forces, and approached Chang'an. As a result, Tian escorted Emperor Xizong to flee to Fengxiang, and then to Xingyuan (興元, in modern Hanzhong, Shaanxi). The imperial officials largely followed Emperor Xizong to Fengxiang, but when he suddenly fled to Xingyuan, few followed (because they were not aware that he had fled further), with Kong and Du Rangneng being among the few who did. Emperor Xizong then commissioned Kong as the chief imperial censor (御史大夫, Yushi Daifu) and ordered him to return to Chang'an and Fengxiang to order the imperial officials to report to Xingyuan. However, when Kong arrived at Fengxiang, the imperial officials — including the chancellors Xiao and Pei Che, who by this point were thoroughly disgusted with Tian's control over the emperor, refused to meet Kong, and even the imperial censors — Kong's subordinates — were finding excuses to refuse to follow him. In anger, Kong stated, "My wife is ill and about to die, and I have left her. If you, gentlemen, are going to care about yourselves this much, this is farewell!" He then met Li Changfu and asked Li Changfu to give him an escort. Li Changfu, impressed, agreed, and had soldiers escort him to Xingyuan. First chancellorship After Kong Wei's arrival in Xingyuan, Emperor Xizong made both him and Du Rangneng deputy ministers of defense, as well as chancellors, with the designation Tong Zhongshu Menxia Pingzhangshi (). After Emperor Xizong subsequently was able to return to Chang'an after Zhu Mei was killed by his own officer Wang Xingyu (who was promised that if he did so, he could succeed Zhu as military governor of Jingnan), Kong was given the additional post of Zuo Pushe (左僕射, one of the heads of the executive bureau), and was given an iron certificate, guaranteeing that he would not be put to death. After Emperor Xizong died in 888 and was succeeded by his brother Emperor Zhaozong, Kong continued to serve as chancellor, and was further created the Duke of Lu. Around the new year 889, when Emperor Zhaozong was set make sacrifices to heaven, the powerful eunuchs (including Yang Fugong, who was instrumental in Emperor Zhaozong's ascension) wanted to participate in