In summer 618, Xue Ju launched an attack on Tang's Jing Prefecture (涇州, roughly modern Pingliang, Gansu), and Tang's Emperor Gaozu sent Li Shimin to resist Xue Ju. Li Shimin established his defenses and refused to engage Xue Ju to try to wear Xue Ju out, but at that time, he was afflicted with malaria, and he let his associates Liu Wenjing and Yin Kaishan () take command, ordering them not to engage Xue Ju. Liu and Yin, however, did not take Xue Ju seriously, and Xue Ju ambushed them at Qianshui Plain (淺水原, in modern Xianyang, Shaanxi), crushing Tang forces and inflicting 50%-60% casualties. Li Shimin was forced to withdraw back to Chang'an, and Liu and Yin were removed from their posts. Hao then suggested to Xue Ju that he should attack Chang'an at once, and Xue Ju agreed, but he then grew ill and died. Xue Rengao succeeded him as emperor, and honored him with the posthumous name of Wu (武, "martial"), but was defeated by and forced to surrender to Li Shimin three months later, even before he could properly bury Xue Ju.