He hailed from the district of Peixian 沛縣 in the commandery of Sishui 泗水郡 (north of the modern province of Jiangsu). In his early years he was a neighbourhood head (tingzhang 亭長). Under the reign of the Qin dynasty 秦 (221-206 BCE) he had to escort a group of prisoners to Mt. Lishan 驪山. On the way to the destination the prisoners deserted, and fearing cruel punishment, he left his post himself and hid in the hilly region of Mt. Mang 芒 and Dang 碭.
In 209, when the grip of the Qin dynasty on the regions crumbled with the rebellion of Chen Sheng 陳勝 and Wu Guang 吳廣, he returned to Peixian and made himself head of a group of rebels. The group was intellectually led by Xiao He 蕭何 and Cao Shen 曹參. Liu Bang declared himself Duke of Pei 沛公 and allied with Xiang Liang 項梁, a powerful leader of the southern aristocracy. Xiang Liang's nephew Xiang Yu 項羽 soon took over command.
After the battle of Julu 巨鹿 (modern Pingxiang 平鄉, Hebei), the newly proclaimed King Huai of Chu 楚懷王 dispatched Liu Bang to conquer the capital of the Qin dynasty in the region of Guangzhong 關中. In 207 the Infant King of Qin 秦王子嬰 surrendered to Liu Bang. The victor immediately declared the oppressive law (hèfa [sic!] 荷法) of the Qin dynasty as invalid and proclaimed that a just penal law would be introduced. Xiang Yu, after defeating the remnants of the Qin troops, advanced to the Hongmen Pass 鴻門 and, envious of Liu Bang's easy victory over the Qin, threatened to attack him. Liu Bang's follower Zhang Liang 張良 suggested that Liu might personally visit the stronger Xiang Yu and beg for pardon.
Xiang Yu accepted and made Liu Bang one of the kings that were to reign the former territory of the Qin dynasty. Xiang Yu called himself the Hegemonial King of Western Chu 西楚霸王. Liu Bang's kingdom was the region of the River Han 漢, a mountainous area in the west that Xiang Yu estimated as remote and not sufficient to provide enough ressources to wage ware against himself. Nevertheless Liu Bang, the King of Han, immediately started a war against whom he perceived as a usurper.
Although Liu Bang was militarily inferior and was often defeated by Xiang Yu in the first years, he disposed of the ability to make use of competent advisors. In the course of time he could win over one after the other of the kings to side with him against Xiang Yu. In 202 the able military leaders Han Xin 韓信 and Peng Yue 彭越 change side to Liu Bang and supported his campaigns. The joint army of the allies encircled Xiang Yu at Gaixia 垓下 (modern Lingbi 靈壁, Anhui). Xiang Yu managed to escape but shortly after committed suicide.
In the second month of 202 Liu Bang proclaimed himself as emperor of the Han dynasty. His first capital was Luoyang 洛陽, but he soon moved his capital to Chang'an 長安 (modern Xi'an 西安). The beginning of the Han dynasty can be defined as 206, when Liu Bang was made King of Han, or 202, when he became emperor.
The first years of Liu Bang's reign as emperor were characterized by a slow recovery from the long period of wars. A lot of peasants had left their home and wandered around in search for a better life. The state granaries were emptied, and the state disposed of virtually no tax revenues. Liu Bang therefore lowered field taxes to one fifteenth of the harvest. People that had sold themselves as slaves were declared free commoners, soldiers were brought back into civilian life, and the obligation to deliver corvée labour was reduced to an acceptable level. Troops were given land that they had to make arable and to cultivate. Persons were encouraged to leave the mountains and swamps and return back to their home districts to be registered for taxation. Merchants were prohibited to wear silk clothes and were not allowed to travel in carts. Everyone had thus to participate in a frugal life to gradually bring the economy back to normality.
After the war against Xiang Yu was over, Liu Bang had to reward those of the powerful commanders that had sided with him. He therefore did not entirely follow the example of the Qin by administering the empire in commanderies (jun 郡), but also followed the custom of the old Zhou dynasty 周 (11th cent.-221 BCE) and made Han Xin (King of Qi 齊, later King of Chu 楚), Peng Yue (King of Liang 梁), Ying Bu 英布 (King of Huainan 淮南), Lu Wan 盧綰 (King of Yan 燕), Zhang Er 張耳 (King of Zhao 趙), Xin, the King of Han 韓王信 (King of Dai 代) and Wu Rui 吳芮 (King of Changsha 長沙) as kings (wang 王). Later, when only members of the imperial family were entitled to bear the title of king ("prince", regional ruler), these seven persons were called the "non-relative regional rulers" (yixing zhuhou wang 異姓諸侯王).
The territories these persons were entrusted with covered a very large area and constituted a great danger for Liu Bang's own imperial domain. It took him several years to cut back these territories. Some of the kings were demoted, some executed as rebels. Only Wu Rui was able to transmit his state to his sons and grandsons. The other kingdoms were given into the hands of Liu Bang's brother and his many sons, many of them were of minor age. At that time Liu Bang is said to have sworn an oath (the White Horse Oath 白馬之盟) with his most trusted followers, stating that if ever a non-Liu would become or make himself a king, everyone should attack him.
During the long years of war, the steppe federation of the Xiongnu 匈奴 had regained power and again endangered the northern sphere of the empire. Liu Bang, encircled during a campaign against the Xiongnu, could not but appease them with tributes of silk and the promise of sent a Han princess for marriage (the policy of heqin 和親 "peace by matrimony").
Liu Bang, as a man of relatively low origins, dispised the academicians and the Confucian scholars. He had, in his words, conquered the world on horseback, and saw now need in the study of the Confucian Classics. Lu Jia 陸賈 admonished him that he had to follow the advice of the Confucian scholars, because the world could not be governed from horseback but only with the knowledge of rituals and by bureaucratic procedures. Counsellor-in-chief Xiao He compiled a new law code that was to substitute the harsh penal law code of the Qin dynasty. The Hanlü jiuzhang code 漢律九章 has only survived in fragments.
The empress of Liu Bang was Lü Zhi 呂雉 who had born him the son Liu Ying 劉盈 (known as Emperor Hui 漢惠帝). Liu Bang did not love the weak Prince Ying very much and preferred his son Ruyi 如意, born to him by a Lady Qi 戚夫人. He tried several times to make Ruyi the crown prince, but Empress Lü and several of his ministers admonished him not to do so.
During a campaign against King Ying Bu, Liu Bang was wounded severely by an arrow. On his deathbed he laid governmental affairs into the hands of Xiao He, Chen Ping 陳平 and Zhou Bo 周勃. The latter should play an eminent role in quelling the rebellion of the Lü family.
The temple name of Liu Bang is Han Gaozu. He was buried in the tomb hill Zhangling 長陵.