The history of the Great Wall of China began when fortifications built by various states during the Spring and Autumn (771–476BC) and Warring States periods (475–221BC) were connected by the first emperor of China, Qin Shi Huang, to protect his newly founded Qin dynasty (221–206BC) against incursions by nomads from Inner Asia. The walls were built of rammed earth, constructed using forced labour, and by 212 BC ran from Gansu to the coast of southern Manchuria.

Later dynasties adopted different policies towards northern frontier defense. The Han (202BC – 220AD), the Northern Qi (550–574), the Jurchen-ruled Jin (1115–1234), and particularly the Ming (1369–1644) were among those that rebuilt, re-manned, and expanded the Walls, although they rarely followed Qin's routes. The Han extended the fortifications furthest to the west, the Qi built about of new walls, while the Sui mobilised over a million men in their wall-building efforts. Conversely, the Tang (618–907), the Song (960–1279), the Yuan (1271–1368), and the Qing (1644–1912) mostly did not build frontier walls, instead opting for other solutions to the Inner Asian threat like military campaigning and diplomacy.

Although a useful deterrent against raids, at several points throughout its history the Great Wall failed to stop enemies, including in 1644 when the Qing troops marched through the gates of the Shanhai Pass and replaced the most ardent of the wall-building dynasties, the Ming, as rulers of China proper.

The Great Wall of China visible today largely dates from the Ming dynasty, as they rebuilt much of the wall in stone and brick, often extending its line through challenging terrain. Some sections remain in relatively good condition or have been renovated, while others have been damaged or destroyed for ideological reasons, deconstructed for their building materials, or lost due to the ravages of time. For long an object of fascination for foreigners, the wall is now a revered national symbol and a popular tourist destination.

Geographical considerations

The conflict between the Chinese and the nomads, from which the need for the Great Wall arose, stemmed from differences in geography. The 15" isohyet marks the extent of settled agriculture, dividing the fertile fields of China to the south and the semi-arid grasslands of Inner Asia to the north. The climates and the topography of the two regions led to distinct modes of societal development.

According to the model by sinologist Karl August Wittfogel, the loess soils of Shaanxi made it possible for the Chinese to develop irrigated agriculture early on. Although this allowed them to expand into the lower reaches of the Yellow River valley, such extensive waterworks on an ever-increasing scale required collective labour, something that could only be managed by some form of bureaucracy. Thus the scholar-bureaucrats came to the fore to keep track of the income and expenses of the granaries. Walled cities grew up around the granaries for reasons of defence along with ease of administration; they kept invaders out and ensured that citizens remained within. These cities combined to become feudal states, which eventually united to become an empire. Likewise, according to this model, walls not only enveloped cities as time went by, but also lined the borders of the feudal states and eventually the whole Chinese empire to provide protection against raids from the agrarian northern steppes.

The steppe societies of Inner Asia, whose climate favoured a pastoral economy, stood in stark contrast to the Chinese mode of development. As animal herds are migratory by nature, communities could not afford to be stationary and therefore evolved as nomads. According to the influential Mongolist Owen Lattimore this lifestyle proved to be incompatible with the Chinese economic model. As the steppe population grew, pastoral agriculture alone could not support the population, and tribal alliances needed to be maintained by material rewards. For these needs, the nomads had to turn to the settled societies to get grains, metal tools, and luxury goods, which they could not produce by themselves. If denied trade by the settled peoples, the nomads would resort to raiding or even conquest.

Potential nomadic incursion from three main areas of Inner Asia caused concern to northern China: Mongolia to the north, Manchuria to the northeast, and Xinjiang to the northwest. Of the three, China's chief concern since the earliest times had been Mongoliathe home of many of the country's fiercest enemies including the Xiongnu, the Xianbei, the Khitans, and the Mongols. The Gobi Desert, which accounts for two-thirds of Mongolia's area, divided the main northern and southern grazing lands and pushed the pastoral nomads to the fringes of the steppe. On the southern side (Inner Mongolia), this pressure brought the nomads into contact with China.

For the most part, barring intermittent passes and valleys (the major one being the corridor through Zhangjiakou and the Juyong Pass), the North China Plain remained shielded from the Mongolian steppe by the Yin Mountains. However, if this defence were breached, China's flat terrain offered no protection to the cities on the plain, including the imperial capitals of Beijing, Kaifeng, and Luoyang. Heading west along the Yin Mountains, the range ends where the Yellow River circles northwards upstream in the area known as the Ordos Looptechnically part of the steppe, but capable of irrigated agriculture. Although the Yellow River formed a theoretical natural boundary with the north, such a border so far into the steppe was difficult to maintain. The lands south of the Yellow Riverthe Hetao, the Ordos Desert, and the Loess Plateauprovided no natural barriers on the approach to the Wei River valley, the oft-called cradle of Chinese civilization where the ancient capital Xi'an lay. As such, control of the Ordos remained extremely important for the rulers of China: not only for potential influence over the steppe, but also for the security of China proper. The region's strategic importance combined with its untenability led many dynasties to place their first walls here.

Although Manchuria is home to the agricultural lands of the Liao River valley, its location beyond the northern mountains relegated it to the relative periphery of Chinese concern. When Chinese state control became weak, at various points in history Manchuria fell under the control of the forest peoples of the area, including the Jurchens and the Manchus. The most crucial route that links Manchuria and the North China Plain is a narrow coastal strip of land, wedged between the Bohai Sea and the Yan Mountains, called the Shanhai Pass (literally the "mountain and sea pass"). The pass gained much importance during the later dynasties, when the capital was set in Beijing, a mere away. In addition to the Shanhai Pass, a handful of mountain passes also provide access from Manchuria into China through the Yan Mountains, chief among them the Gubeikou and Xifengkou ().

Xinjiang, considered part of the Turkestan region, consists of an amalgamation of deserts, oases, and dry steppe barely suitable for agriculture. When influence from the steppe powers of Mongolia waned, the various Central Asian oasis kingdoms and nomadic clans like the Göktürks and Uyghurs were able to form their own states and confederations that threatened China at times. China proper is connected to this area by the Hexi Corridor, a narrow string of oases bounded by the Gobi Desert to the north and the high Tibetan Plateau to the south. In addition to considerations of frontier defence, the Hexi Corridor also formed an important part of the Silk Road trade route. Thus it was also in China's economic interest to control this stretch of land, and hence the Great Wall's western terminus is in this corridorthe Yumen Pass during Han times and the Jiayu Pass during the Ming dynasty and thereafter.

Pre-imperial China (7th century – 221 BC)

One of the first mentions of a fortification built against northern invaders is found in the poem War Chariot (出车), dated from the 7th century BC, recorded in the Classic of Poetry. The poem tells of a king, now identified as King Xuan (r.827–782BC) of the Western Zhou dynasty (1046–771BC), who commanded General Nan Zhong () to build a fortification in the northern regions to fend off the Xianyun. The Xianyun, whose base of power was in the Ordos region, were regarded as part of the charioteering Rong tribes, and their attacks aimed at the early Zhou capital region of Haojing were probably the reason for King Xuan's response.

The fall of the Western Zhou dynasty in 771 BC redistributed power to the states that had acknowledged Zhou's nominal rulership. The rule of the Eastern Zhou dynasty was marked by bloody interstate anarchy. With smaller states being annexed and larger states waging constant war upon one another, many rulers came to feel the need to erect walls to protect their borders. Of the earliest textual reference to such a wall was the State of Chu's wall of 656 BC, of which were excavated in southern Henan province in the modern era. However the Chu border fortifications consisted of many individual mountain fortresses; they do not constitute to a lengthy, single wall. The State of Qi also had fortified borders up by the 441BC, and the extant portions in Shandong province had been christened the Great Wall of Qi. Even non-Chinese states built walls, such as the Di state of Zhongshan and the Yiqu Rong, whose walls were intended to defend against the Zhao and Qin.

The State of Wei built two walls. One were built in the northwest of the frontier, named the Hexi Wall, completed in 361 BC. One section was built in the south of the state, bordering the Han state, called the Henan Wall, was completed in 356 BC. The extant ruins of the western wall can be found in Hancheng, Shaanxi.

The Wall of the Zheng was initially constructed in 355 BC. Zheng was later defeated by the Han, which continually constructed the wall. This section of wall is called the Wall of Zhenghan. Its ruins are in present-day Xinzheng City in Henan Province.

Of these walls, those of the northern states Yan, Zhao, and Qin were connected by Qin Shi Huang when he united the Chinese states in 221 BC. The walls, known as Changcheng (長城) – literally "long walls", but often translated as "Great Wall" – were mostly constructed of tamped earth, with some parts built with stones. Where natural barriers like ravines and rivers sufficed for defence, the walls were erected sparingly, but long fortified lines were laid where such advantageous terrains did not exist. Often in addition to the wall, the defensive system included garrisons and beacon towers inside the wall, and watchtowers outside at regular intervals. In terms of defence, the walls were generally effective at countering cavalry shock tactics, but there are doubts as to whether these early walls were actually defensive in nature. Nicola Di Cosmo points out that the northern frontier walls were built far to the north and included traditionally nomadic lands, and so rather than being defensive, the walls indicate the northward expansions of the three northern states and their desire to safeguard their recent territorial acquisitions. This theory is supported by the archeological discovery of nomadic artifacts within the walls, suggesting the presence of pre-existing or conquered barbarian societies. It is entirely possible, as Western scholars like di Cosmo and Lattimore suggest, that nomadic aggression against the Chinese in the coming centuries was partly caused by Chinese expansionism during this period.

Great Wall of Qi and Lu