The Great Wall of China was primarily built to defend against invasions and raids by northern nomadic tribes, who were skilled horsemen and posed a significant threat to the settled agricultural societies of China. The wall acted as a physical barrier to block the advance of nomadic cavalry and delayed raids, allowing Chinese troops to respond and protect their lands. Additionally, the wall helped stabilize border communities by protecting agricultural production, controlled economic exchanges through regulated trade passes, and symbolized the strength and unity of Chinese empires over many dynasties. The construction of the wall spanned over 20 dynasties, starting from earlier state walls, being unified and expanded notably during the Qin dynasty, and continuing through the Ming dynasty, which built much of the wall seen today. It also served purposes beyond defense, such as controlling immigration and trade along the Silk Road, and consolidating territorial control in various historical periods.