Hanzhong Campaign
In 219, after Liu Bei defeated his rival Cao Cao in the Hanzhong Campaign and seized control of Hanzhong Commandery, he declared himself "King of Hanzhong" () and designated Chengdu as the capital of his kingdom. Before leaving Hanzhong, he asked his subjects to nominate one of his generals to remain behind and guard Hanzhong. His subjects nominated Zhang Fei, who also strongly believed that he would most likely be chosen. However, much to everyone's surprise, Liu Bei chose Wei Yan instead and appointed him as General Who Guards Distant Lands () and acting Administrator of Hanzhong ().