Even before the first Chinese dynasty, complex societies inhabiting the area now known as China organized into settlements, and the most important settlements were protected by rammed earth walls. The first dynasty, the Shang (1600-1050 BC), built large walls as early as around 1,550 BC. Differing from later walls, which were built along a strategic defense line, these walls were built to enclose the settlements and areas. The Shang would eventually be conquered from the west by the Zhou Dynasty (1046-256 BC), which developed a complex system of government. In fact, it was the Zhou system’s decline that Confucius (551-479 BC) witnessed and drew from greatly for his political philosophy. The Zhou also created walled cities, and it was at this time that the first major conflicts with northern tribesman, the Xianyun, were recorded.
As the newly independent states vied for supremacy in a state of constant warfare, northern barbarians were also a constant menace. Eventually, the Chinese succeeded in eliminating many of those on their immediate northern border, but it was a bittersweet victory because it meant there was no longer a buffer between China and the even fiercer Mongols further north. This new proximity led to increased cultural exchange, as well as the Chinese adoption of nomadic fighting techniques.
Ultimately, it was the wall of the state of Qi that was the first to earn the name great (literally: long) wall, because the state of Qin proved most adept at the new warfare and conquered all the others. It was this dynasty that unified the kingdoms under the name of China (Zhongguo or "Middle Kingdom"), but put simply, the Qin were a war machine. They defeated the Mongols north of the border and expanded their control there, while also fighting expansionary wars in all directions.
The Han Dynasty: The History and Legacy of Ancient China’s Most Influential Empire examines how the Han dynasty took control of China and the impact of their reign over several centuries.