In 217, Cao Cao's rival Liu Bei, who had taken over Yi Province (covering present-day Sichuan and Chongqing) in 215, launched a campaign to wrestle control of Hanzhong from Cao Cao. When Liu Bei's forces reached Yangping Pass (陽平關; in present-day Ningqiang County, Shaanxi), Xiahou Yuan led his men to resist the enemy and both sides were locked in a stalemate for nearly a year.