Wei Yan 魏延, courtesy name Wenzhang 文長, was a military commander of the state of Shu-Han 蜀漢 (221-263), one of the Three Empires 三國 (220~280 CE).
Wei hailed from Yiyang 義陽 (today's Tongbai 桐柏, Henan), and served the warlord Liu Bei 劉備 (161-222) as a military officer. When Liu Bei conquered the Sichuan Basin, Wei Yan was bestowed the title of General of the Serrated Gate (yamen jiangjun 牙門將軍). Wei was appointed governor (taishou 太守) of Hanzhong 漢中, a critical border region to the kingdom of Wei 曹魏 (220-265). He thus had an important function in the defence of the empire of Shu. When Liu Bei adopted the title of emperor, Wei Yan was given the title of General Defending the North (zhenbei jiangjun 鎮北將軍) and was invested as Neighbourhood Marquis of Duting 都亭侯. He bore the title of the Counsellor's Cavalry Commander (chengxiang sima 丞相司馬), and was regional inspector (cishi 刺史) of the province of Liangzhou 涼州.
In 230, he carried out a military campaign against the Qiang tribes 羌 and defeated the army of Wei under general Guo Huai 郭淮 (d. 255). He was given the titles of Commander of the Front Army (qianjun shi 前軍師) and Grand General Conquering the West (zhengxi da jiangjun 征西大將軍), and elevated to the rank of Marquis of Nanzheng 南鄭侯. In 234, when chief minister Zhuge Liang 諸葛亮 (181-234) passed away, Wei Yan and Yang Yi 楊儀 competed for military domination in the north. Wei's unjust attack on his colleague proved fatal, and he had to flee, but was killed by Ma Dai 馬岱. His relatives were executed in three generations (yi sanzu 夷三族).