But they were defeated by Huang Quan who then seized control of Badong (巴東), Baxi (巴西) and Ba (巴) commanderies.
Hence, Liu Bei came to a border treaty with Sun Quan, who had seized Changsha (長沙), Guiyang (桂陽) and Lingling (零陵) commanderies in southern Jing Province from him.
[10] In December 217,[1] Liu Bei's adviser Fa Zheng analysed the reason Cao Cao left Xiahou Yuan to guard Hanzhong Commandery and didn't push to conquer Yi province was not because of a lack of strength or insight but because he met some internal problems and was needed back at the capital.
Fa Zheng also believed that Xiahou Yuan and Zhang He's ability didn't match those of Liu Bei's commanders, so the pair could not defend Hanzhong Commandery.
At the same time, Liu Bei also sent Zhang Fei, Ma Chao, Wu Lan (吳蘭), Lei Tong (雷銅) and Ren Kui (任夔) to attack Wudu Commandery (武都郡), and they garrisoned at Xiabian County (下辨縣).
In April 218,[1] Zhang Fei and Ma Chao's army garrisoned at Gushan (固山), where they spread news that they were going to blockade the enemy's retreat route.
Cao Hong wanted to attack Wu Lan at Xiabian County, but the other officers were suspicious of Zhang Fei's movements.
Between May and August (summer) 218,[1] Liu Bei sent Chen Shi to attack Mamingge, but the latter was defeated by Xu Huang, and some of the fleeing soldiers fell into the deep valleys during their escape.
In February 219,[1] to break the deadlock, Liu Bei crossed the Mian River (沔水) south of Yangping Pass and advanced towards Hanzhong Commandery through the mountains.
In response, Xiahou Yuan and Zhang He led their forces out in an attempt to take control of higher ground, and they made camp at Zouma Valley (走馬谷).
Liu Bei ordered his men to shout loudly and beat the drums, and sent Huang Zhong to charge at the enemy.
The mettlesome soldiers of Huang Zhong broke through the enemy lines and slew Xiahou Yuan and Zhao Yong, while Zhang He fled with his surviving troops to north of the Han River, where they set up a camp.
Du Xi and Guo Huai regrouped their scattered troops and (unofficially) nominated Zhang He to replace Xiahou Yuan.
When Cao Zhen arrived, he directed Xu Huang to attack Gao Xiang, an officer under Liu Bei.
Upon reaching camp, Zhao Yun ordered the gates to be opened, flags and banners to be lowered, and the beating of war drums to be stopped.
[26] In July 219, one month after the capture of Hanzhong, Liu Bei sent Meng Da to attack Fangling Commandery (房陵郡) via Zigui County.
Meng Da defeated and killed Fangling Commandery's Administrator, Kuai Qi (蒯祺), and took control of the area.
[28] Word of Liu Bei's victory at Hanzhong eventually reached Guan Yu, who was, at the time, stationed in southern Jing province.