Zhang Juhan was born in 858, during the reign of
Emperor Xuānzong of Tang, but it is not known where he was born or how he came to become a eunuch. Early in the
Xiantong era of Emperor Xuānzong's son and successor
Emperor Yizong of Tang (860-874), he was adopted by the eunuch Zhang Congmei (張從玫). (Therefore, it appeared likely that his original name was not Zhang.) Because Zhang Congmei was a eunuch official (director of the office of
ladies in waiting), Zhang Juhan was able to, through that heritage, become a eunuch official as well. At one point, he served as the eunuch monitor of the army at Rong District (容管, headquartered in modern
Yulin,
Guangxi). In 883, during the reign of Emperor Yizong's son and successor
Emperor Xizong, Zhang Juhan was recalled from Rong District to serve as an assistant at the Hall of Imperial Scholars (學士院,
Xueshiyuan). He was subsequently made an assistant to the directors of palace communications (樞密承旨,
Xumi Chengzhi), as well as the director of office of palace treasury (內府令,
Neifu Ling). — he gave Zhang the greater title of
Zhong Changshi (中常侍) and sent him to Lulong Circuit (盧龍, headquartered in modern
Beijing), to serve as Lulong's eunuch monitor. Later, when Emperor Zhaozong was set to summon Zhang back to the capital
Chang'an, Lulong's military governor (
Jiedushi)
Liu Rengong submitted a petition that Zhang be kept at Lulong, and Zhang ended up staying at Lulong. Liu hid Zhang and executed an inmate in his stead, claiming that he had already executed Zhang. In 906, Zhu launched a major attack on Liu's domain, attacking Yichang Circuit (義昌, headquartered in modern
Cangzhou,
Hebei), then governed by Liu's son
Liu Shouwen. Liu Rengong sought aid from
Li Keyong the military governor of Hedong Circuit (河東, headquartered in modern
Taiyuan,
Shanxi). Li agreed, but under the provision that Liu send troops to Hedong so that the Hedong and Lulong troops could jointly attack Zhaoyi Circuit (昭義, headquartered in modern
Changzhi,
Shanxi), which had fallen under Zhu's control at that time, to try to relieve the pressure on Yichang. Liu sent Zhang and the secretary Ma Yu (馬鬱) with an army to Hedong, to join the attack on Zhaoyi. After the campaign, however, Li kept Zhang and did not return him to Lulong. After Li captured Zhaoyi and put his adoptive nephew
Li Sizhao in command of the circuit, Zhang was made the eunuch monitor of the Zhaoyi army, personally commanding the 3,000 soldiers from Lulong. == During Jin ==