In 215, Guo Huai accompanied Cao Cao on a campaign against a rival warlord, Zhang Lu, in Hanzhong Commandery. After defeating Zhang Lu and capturing Hanzhong Commandery, Cao Cao left his general Xiahou Yuan behind to guard Hanzhong against possible attacks by another rival warlord, Liu Bei, who was in the nearby Yi Province (covering present-day Sichuan and Chongqing). Guo Huai also remained in Hanzhong and served as a Major () under Xiahou Yuan's command.