As Yuwen Huaji approached Luoyang, the rebel leader Li Mi, who controlled the region, resisted him. Yuwen Huaji initially could not get past Li, and therefore went to and took over Dong Commandery (東郡, roughly modern Anyang, Henan). Both Li Mi and the Sui officials at Luoyang (who had, after hearing of Emperor Yang's death, declared Emperor Yang's grandson Yang Tong the Prince of Yue emperor) were apprehensive of Yuwen Huaji's next move, and they, previously enemies, entered into an alliance where Li, previously showing imperial ambitions of his own, accepted a Sui-bestowed title of Duke of Wei and nominally submitted to Yang Tong. Yuwen Huaji made several attacks on Li Mi but could not prevail. Li, knowing that Yuwen Huaji's food supplies were running out, pretended to offer peace to Yuwen, agreeing to supply Yuwen's army with food, but instead planning to withhold food and, once Yuwen's food supplies did run out, attack. Li's plans, however, became known by Yuwen, and he in turn made a surprise attack on Li, nearly killing Li, but Li's general Qin Shubao protected Li from death, and eventually Yuwen was repelled. Yuwen, unable to gain food, headed north away from Li, and Li did not trail him. Many of his soldiers surrendered to Li, but he still had some 20,000 men by this point.