In spring 619, Yuwen Huaji attacked Yuan Baozang (元寶藏), a general previously under Li Mi. (Li Mi had been defeated by the Sui general Wang Shichong in fall 618 and subsequently fled to the newly established Tang Dynasty, although he then tried to rebel against Tang in winter 618 and was killed around the new year 619.) Yuan surrendered to Tang, and subsequently, the Tang general Li Shentong (李神通, a cousin of the Tang emperor Emperor Gaozu), in turn attacked Yuwen Huaji. Yuwen Huaji could not resist Li Shentong's attacks and fled east to Liaocheng. Li Shentong trailed him and put Liaocheng under siege.