Liu Zhang appointed Li Yan as the Prefect of Chengdu, and once again, Li Yan distinguished himself on his new post. Later, when the warlord Liu Bei invaded Yi Province, Li Yan was assigned as an army controller after initial resistance proved futile. Li was supposed to repel the invading army at Mianzhu, a strategic stronghold that laid before Yi Province's capital Chengdu; however, Li Yan led his subordinates to surrender to Liu Bei when the latter arrived. For his timely defection, Li Yan was appointed as a Major-General.