Zhang Quanyi () (852 – April 29, 926), né Zhang Juyan () or Zhang Yan (), known as Zhang Zongshi () during Later Liang, courtesy name Guowei (), formally Prince Zhongsu of Qi (), was a late Tang Dynasty warlord who later was a senior official during the succeeding Later Liang and Later Tang. He was credited for rebuilding the city of Luoyang from utter destruction from the warfares in the late Tang period into a prosperous city. During Tang Dynasty Background and service under Huang Chao Zhang Quanyi was born in 852, during the reign of Emperor Xuānzong. His biography in the History of the Five Dynasties indicated that he was originally named Zhang Juyan, and his biography in the New History of the Five Dynasties indicated that he was originally named Zhang Yan. His family was from Linpu (臨濮, in modern Heze, Shandong), and both his grandfather Zhang Lian () and father Zhang Cheng () were farmers. Zhang Quanyi himself served as a farm inspector for the Linpu County government, but in his service was often insulted by the county magistrate. Therefore, when, late in the Qianfu era (874-879) of Emperor Xuānzong's grandson Emperor Xizong, when the region was overrun by the major agrarian rebel Huang Chao, Zhang joined Huang's army. After Huang captured the Tang imperial capital Chang'an and forced Emperor Xizong to flee to Chengdu around the new year 881, Huang established a new state of Qi with himself as emperor. Zhang served in Huang's government as the minister of civil service affairs (吏部尚書, Libu Shangshu) and the director of transportation. Service under Zhuge Shuang and Zhuge Zhongfang After Huang Chao was eventually defeated by Tang forces and chased out of Chang'an, Zhang Quanyi joined the army of the Tang general Zhuge Shuang the military governor (Jiedushi) of Heyang Circuit (河陽, headquartered in modern Jiaozuo, Henan). He distinguished himself serving under Zhuge, and Zhuge eventually made him the prefect of Ze Prefecture (澤州, in modern Jincheng, Shanxi). Zhuge died in 886. Zhang and another officer of Zhuge's, Liu Jing (), supported Zhuge's son Zhuge Zhongfang () as acting military governor. Liu, however, controlled the governance of the circuit, drawing resentment from other officers. Late in 886, Liu became suspicious of the officer Li Hanzhi, and he decided to use Luoyang as a base to launch a surprise attack on Li's base at Minchi (澠池, in modern