People were here long before anyone wrote a capital's name. A hominid skull was found at Lantian in 1964, and Banpo preserves a 6,000-year-old village with houses, pottery workshops and a burial ground. In 2008 archaeologists reported Neolithic city ruins of similar age at Yangguanzhai. The Shaanxi History Museum holds some of the best examples of Banpo's pottery.
The Zhou, Qin and Han all ruled from this plain. Qin Shi Huang, who unified China in 221 BC, started his tomb and its clay army almost as soon as he took the throne, and the army was buried east of the city. In 202 BC the Han founder Liu Bang set up his capital at Chang'an, the date usually given for the city's founding. His Weiyang Palace covered 4.8 square kilometres, more than six times the Forbidden City.
In the second century BC the Han emperor Wu sent Zhang Qian west, and Chang'an became the eastern end of the Silk Road. The trade left religions behind: a Syriac missionary named Alopen arrived in 635, and the Great Mosque was built by a Muslim community that settled in China for the Silk Road trade.
The Sui founded a new city south-east of the Han one in 582, and the Tang renamed it Chang'an. Its grid still shapes Xi'an's streets. The monk Xuanzang came back from India in the mid-600s and set up a school to translate his Sanskrit texts, and the Big Wild Goose Pagoda was raised to hold them. The Small Wild Goose Pagoda followed in 707; a 1556 earthquake knocked it down to 43 m.
Chang'an did not last. At the start of the 10th century its people were forced to move to Luoyang, and only a small corner of the great city stayed inhabited. The Ming built the wall you walk today in 1370, around a much smaller city, with a moat outside it. The name Xi'an dates from 1369, early in the Ming.
The 20th century was hard on the city. In October 1911 revolutionaries stormed the Manchu quarter and most of its roughly 20,000 residents were killed. In December 1936 two generals, Zhang Xueliang and Yang Hucheng, led the Xi'an Incident, an episode that pushed the Nationalists and Communists into a united front against Japan. Xi'an was never taken. Residents sheltered in around 1,000 bunkers dug into the wall's thick base.
The People's Liberation Army took the city in May 1949, and in the Mao era Xi'an was developed further under the Third Front programme. The wall was renovated in 1983, and the Terracotta Army became a UNESCO World Heritage Site in 1987. From December 2021, after more than 250 cases were reported, the whole city went into strict lockdown.