recommendation, Zhang Wenwei was made a roving surveyor for the office. After Huang was defeated and Emperor Xizong returned to Chang'an in 885, Zhang was first made an imperial censor with the title Jiancha Yushi (監察御史); then (either successively or holding the offices all at once) Zuo Bujue (左補闕), a low-level advisory official at the examination bureau of government (門下省, Menxia Sheng); an imperial censor with the title Dianzhong Shi Yushi (殿中侍御史); an imperial chronicler with the title Qiju Sheren (起居舍人); and Sixun Yuanwailang (司勛員外郎), a low-level official at the ministry of civil service affairs (吏部, Libu). He was then promoted to a supervisory position at the ministry of civil service affairs, with the title Sixun Langzhong (司勛郎中) and put in charge of drafting edicts. After serving in those roles for a year, he was made Zhongshu Sheren (中書舍人). After his mother's death, he left governmental service to observe a mourning period for her. After Zhang finished observing the mourning period, he returned to the imperial government as a Zhongshu Sheren. He was soon thereafter made the chief imperial scholar (翰林學士承旨, Hanlin Xueshi Chengzhi). As then-reigning Emperor Zhaozong (Emperor Xizong's brother and successor) had just returned to Chang'an, and the imperial authority was extremely weak at that time, edicts that Zhang drafted had to be, and were, appropriately delicate in language but assertive, and was much praised for their propriety. He was then given the additional post of deputy minister of census (戶部侍郎, Hubu Shilang), and later was made the deputy minister of rites (禮部侍郎, Libu Shilang) but no longer imperial scholar by that point. Chancellorship As of 905, Zhang was still serving as the deputy minister of rites—at that time, at Luoyang, which had been made the capital after the powerful warlord Zhu Quanzhong the military governor of Xuanwu Circuit (宣武, headquartered in modern Kaifeng, Henan) had forcibly moved Emperor Zhaozong from Chang'an to Luoyang in 904,—under Emperor Zhaozong's son and successor Emperor Ai, as Zhu had had Emperor Zhaozong assassinated late in 904. In 905, the chancellor Liu Can, an associate of Zhu's, had alienated Zhu from the other chancellors Pei Shu, Dugu Sun, and Cui Yuan; Pei, Dugu, and Cui were therefore removed from chancellor offices, while Zhang and Yang She were made chancellors, with the designation Tong Zhongshu Menxia Pingzhangshi (同中書門下平章事). He was also made Zhongshu Shilang (中書侍郎), the deputy head of the legislative bureau, and