In the late 870s, local militias were formed to resist the rebel Wang Ying, and among the soldiers were Hang Prefecture natives Dong Chang and Qian Liu. In 882, warlord Liu Hanhong, who was based in neighboring Yue Prefecture, wanted to take over Hang Prefecture from Dong Chang. He was soundly defeated by Dong Chang's force led by Qian Liu. In 886, Dong Chang promised Hang Prefecture to Qian Liu if he could destroy Liu Hanhong; Qian Liu did just that, capturing Liu Hanhong and taking over his territory. In 887, Qian Liu took over Hang Prefecture while Dong Chang went to Liu Hanhong's former base in Yue Prefecture. (Qian Liu later attacked and killed Dong Chang in 896.) Qian Liu began a series of massive construction projects in Hang Prefecture in 890. These include the fortification of city walls and the construction of a dam to control the Qiantang River. After the Tang dynasty collapsed in 907, Qian Liu remained independent throughout the ensuing Five Dynasties period, even though like before he continued to pay tributes to the imperial courts in Kaifeng Prefecture (or Henan Prefecture during Later Tang). During the Wuyue kingdom, many Buddhist pagodas were built in Hang Prefecture. These include Baochu Pagoda (963), Liuhe Pagoda (970), and Leifeng Pagoda (975). The inventor Bi Sheng was active in Hang Prefecture, as was Shen Kuo. In December 1120, rebel Fang La took Hang Prefecture and held it until March 1121. In March 1129, Zhao Gou fled the north and arrived with his followers in Hang Prefecture. Note: From 742 to 758 Hang Prefecture was known as Yuhang (Commandery).