Birth and early life
In imperial Han myth, Liu Bang was a descendant of the mythical Emperor Yao, who descended from the Yellow Emperor. It was a common practice among many ancient Chinese noble families to claim descent from the mythical Yellow Emperor, in order to proclaim divine ruling legitimacy.
Liu Bang was born to a peasant family in Zhongyang Village (中陽里), Feng Township (丰邑), Pei County (沛縣) in the state of Chu during the late years of the Warring States period. His parents' names were not recorded in history; they were simply referred to as "Liu Taigong" (劉太公; lit. "Old Sir Liu") and "Liu Ao" (劉媪; lit. "Old Madam Liu"). According to legend, before Liu Bang's birth, his mother was caught in a rainstorm and took shelter under a bridge. At that moment, lightning struck and the sky darkened. Liu Bang's father went to fetch his wife home and saw a dragon hovering above her. She became pregnant and later gave birth to Liu Bang.
It was subsequently recorded that the young Liu Bang was outspoken, charismatic and of great generosity and forbearance. However, he enjoyed loafing, disliked reading, showed no interest in farming and manual labour and frequently ran into trouble with the law, hence his father often called him a "little rascal" for his lazy lifestyle. Liu Bang persisted in his idling ways and depended on his brother's family for food and lodging. When he grew older, he became a good friend and live-in companion of a former retainer of Lord Xinling named Zhang Er (Chinese: 張耳, ? — 202 BCE), who, at the time, was the magistrate of the nearby Waihuang County.
After Qin conquered Chu, Zhang Er went into hiding, and Liu Bang returned to his own home town. He was later recommended and appointed as the local sheriff (亭長) at Sishui Ting (泗水亭) in Pei County, working under the supervision of his close friends Xiao He and Cao Shen, who often helped cover up his delinquent behaviours. He nevertheless forged close relationships with most of the local county bureaucrats, and earned himself a small reputation in the district. Liu Bang was once sent for statute labour in the capital Xianyang, and encountered the First Emperor going on an inspection tour around the nation. Awed by the majestic sight of the royal convoy, he exclaimed, "Alas, this is how a great man should be! (嗟乎，大丈夫當如此也)"
One day, Lü Wen (呂文), a wealthy and influential member of the gentry from Shanfu County, who had recently moved to Pei County, was putting on a feast to host the local elites. Xiao He, who was in charge of helping Lü Wen collect gifts from the visitors, announced that "those who do not offer more than 1,000 coins worth of gifts shall be seated outside the hall". Liu Bang went there without bringing any money and said, "I offer 10,000 coins." Lü Wen saw Liu Bang and was so impressed with him on first sight, that he immediately stood up and welcomed Liu into the hall to sit beside him, despite Xiao He telling him that Liu Bang was not being serious. Lü Wen chatted with Liu Bang, and said, "I used to predict fortunes for many people but I have never before seen someone so exceptional like you." He then offered his daughter Lü Zhi's hand in marriage to Liu Bang. After they were wed, Lü Zhi bore Liu Bang a son Liu Ying (the future Emperor Hui) and a daughter (the future Princess Yuan of Lu).