opined that Li should try to contain Wang's advances and then send part of the army to attack Luoyang while Wang was away. Li himself opined that he should refuse to engage Wang to let Wang's food supplies run out. However, his generals Chen Zhilüe (), Fan Wenchao (), and Shan Xiongxin all advocated a head-on engagement against Wang, and Li accepted their suggestion. In the subsequent Battle of Yanshi, Wang sent his flanks to hide, and when Li engaged him, the flank forces attacked as well, leading to a general rout of Li's forces. Wang captured Yanshi (), where most of Li's officials kept their families, and the family members subsequently sent messages to those officials urging them to surrender. Li tried to withdraw to Luokou, but by the time he got there, Wang had caught up with him, and Bing surrendered Luokou to Wang; Shan surrendered as well. Li himself fled east to Hulao. Li initially considered further fleeing to Liyang, but he was warned that as Xu Shiji was nearly killed when Li killed Zhai Rang, he could not be assured of Xu's loyalty. He tried to reorganize his troops to fight Wang again, but the troops were largely unwilling to fight any further. Li therefore resolved to head west to surrender to Tang. Some 20,000 to 30,000 men followed him. Most of Li's former holdings submitted to Wang—i.e., nominally to Yang Tong. Surrender to Tang and death By winter 618, Li Mi was approaching Chang'an. Tang's Emperor Gaozu initially sent numerous messengers to him to express gratitude and welcome, and Li Mi expected Emperor Gaozu to give him a position equivalent to prime minister. However, once he actually arrived at Chang'an, his men were not respected and were given insufficient supplies. Soon, Emperor Gaozu made him the minister of palace supplies and created him the Duke of Xing. Li was not satisfied, particularly because the Tang officials largely looked down on him, and some demanded bribes. Only Emperor Gaozu himself showed him some respect, still referring to Li Mi as "my younger brother," and gave Li Mi his cousin Lady Dugu in marriage. Meanwhile, while most of Li Mi's holdings had surrendered to Yang Tong, Xu Shiji did not. Li Mi's follower Wei Zheng suggested to Emperor Gaozu that he be sent to encourage Xu to submit to Tang, and Emperor Gaozu sent Wei to do