In spring 618, Emperor Yang was killed at Jiangdu (in modern Yangzhou, Jiangsu) in a coup led by the general Yuwen Huaji. Yuwen soon abandoned Jiangdu and headed back north, toward Luoyang, with the elite Xiaoguo Army (), leading to comprehension both at Luoyang (where Sui officials had declared Emperor Yang's grandson Yang Tong the Prince of Yue emperor) and at Li Mi's headquarters. The enemies made peace, with Li Mi nominally submitting to Yang Tong, as both sides prepared for a joint confrontation with Yuwen. As part of this arrangement, Xu also received a major Sui general title. Li Mi, who had become somewhat alienated with Xu due to Xu's criticism that he was not sufficiently rewarding the soldiers, put Xu in charge of defending Liyang Storage, and Yuwen subsequently put Liyang under siege, but Xu was not only able to withstand the siege but further fought Yuwen outside, defeating him.