Yan Yan was the Grand Administrator of Bajun under Liu Zhang. The dubiously accurate Hanyang guozhi argues that he is actually a native of Bajun, Baishan and that his rank is a misconception of his birthplace. It also states that he was known as the "brave General Yan Yan". When Liu Bei's forces were invited by Liu Zhang, Yan Yan grieved, "It's as if I am alone in a remote mountain, trying to defend a body from the released tiger."

Zhang Fei accompanied Zhuge Liang's entry into Yizhou and approached Bajun. Yan Yan resisted them without applying for a surrender. Yan Yan's forces were defeated and he was captured alive. Zhang Fei angrily barked for Yan Yan's reasons for not submitting. The captured man replied, "Even if Yizhou has generals with their heads cleaved off, it will never have a general who has surrendered." His confidence made Zhang Fei furious and he threatened to kill Yan Yan on the spot. In response, Yan Yan said, "If you are to kill me, then do it. It is not necessary for you to be this angered." Impressed by the utter boldness of the prisoner, Zhang Fei instead untied the ropes bounding Yan Yan and entertained him as a honored guest.