At Cao Cao's instruction, Liu Bei prepared to lead a punitive expedition against Yuan Shu. Before departing, he worried about the defense of Xuzhou City. When Zhang Fei volunteered to take charge, Liu Bei expressed his concerns: "How can I feel assured? You are fond of drinking, and after drinking, you often flog your soldiers without reason. Moreover, you are hot-tempered and frequently refuse to take advice." Only after Zhang Fei's repeated entreaties and promises to mend his ways did Liu Bei entrust him with the task. For safety, he left his advisor, Chen Deng, to assist Zhang.
One day, Zhang Fei invited his subordinate officers to a gathering. "My elder brother instructed me to stay away from wine to ensure I properly guard the city," he said. "Let's have one final drinking party today. Starting tomorrow, we will quit drinking and focus on our duties."
After this announcement, he began toasting everyone. However, when Cao Bao refused his toasts twice, Zhang Fei, already drunk, flared up in anger. He ordered Cao Bao to be flogged fifty times.
After the party, the resentful Cao Bao sent a messenger to the enemy general, Lü Bu, urging him to attack the city that night while Zhang Fei was intoxicated. Lü Bu arrived with 500 horsemen and successfully captured Xuzhou. Zhang Fei awoke to find the city lost. He fought his way out of the enemy troops and fled, leaving Liu Bei's family behind.
When Zhang Fei later met Liu Bei, he was so ashamed that he unsheathed his sword, intending to commit suicide. Liu Bei stopped him just in time.