Li Yan was born in Nanyang. When he was young, he served Liu Biao as a secretary and guardsmen. When Cao Cao invaded, he fled to Yizhou and served Liu Zhang. Liu Bei invaded years later and Li Yan was ordered to have his army defend Mianzhu. Rather than fight, both he and Fei Guan chose to surrender. After the siege of Chengdu, he was appointed the Grand Administrator of Jianwei. He worked together with Zhuge Liang, Fa Zheng and Xu Jing to restore and keep the peace in order for Shu Han. In 218, Ma Qin, Gao Sheng, and others staged a rebellion in Zizhong. Li Yan lead five other Generals of the Right to subdue them and the rebels were quickly dealt with. He was summoned to Liu Bei's bedside in Baidicheng in 222. He and Zhuge Liang were personally entrusted by Liu Bei to guide Liu Shan and oversee internal and external affairs. Li Yan helped perform his liege's last wishes and stayed in Tianshui.