In 215, after Zhang Lu lost to Liu Bei's rival Cao Cao at the Battle of Yangping, he escaped and took shelter in the Bazhong (巴中) region in northeastern Yi Province. Huang Quan cautioned Liu Bei against losing Hanzhong to Cao Cao because Hanzhong was the northern gateway into Yi Province. Liu Bei appointed Huang Quan as an Army Protector (護軍) and led his followers towards Bazhong to receive Zhang Lu, but when they arrived there, Zhang Lu had already returned to Hanzhong and surrendered to Cao Cao. Huang Quan then urged Liu Bei to attack and take Hanzhong.