Hang Prefecture sat at the head of the Hangzhou Bay, which opens to the East China Sea.
During the transition from Sui to Tang, the warlord Shen Faxing first held Yuhang Commandery in the confusion following the assassination of Emperor Yang in 618.
In 653, the woman rebel leader Chen Shuozhen attacked Hang Prefecture and took Yuqian.
In the late Tang dynasty, the rebel Huang Chao briefly occupied Hang Prefecture twice, first in 878 and later in 880.
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.
[12] In March 1129, Zhao Gou fled the north and arrived with his followers in Hang Prefecture.