Beijing's history stretches back to the most distant of times: in the area southwest of the city, the famous "Peking Man" of Zhoukoudian was discovered, dating back hundreds of thousands of years.
The city we know today took shape much later, however. During the Tang dynasty (618–907), the city was known as Youzhou and served as an important military and administrative center in northern China — though it was not the imperial capital, which was instead Chang'an (present-day Xi'an).
It later became part of the Khitan Empire — and thus not part of the Chinese empire in the strict sense — during the Liao dynasty (907–1125). The city, then known as Nanjing, became the southern capital of the Khitan (938), a nomadic people from what is now Inner Mongolia and the surrounding regions. The city was fortified, but its beating heart did not yet coincide with today's urban center, where the Forbidden City and the main districts now stand. The city's center of gravity lay to the southwest, in the area now surrounding Lianhuachi (Lotus Park) and Beijing West Railway Station.
Later, under the Jin dynasty, founded by the Jurchen people (1115–1234), who conquered the region, Beijing became the capital of the Jin empire under the name Zhongdu.
The beginnings of the city's transformation into its modern form came with the Yuan dynasty. When the Mongols, under the command of Kublai Khan, conquered China and established their capital in Beijing (proclaimed in 1271), the city was shifted to the northwest and an entirely new urban layout was designed. It was during this period that Beijing's great artificial lakes — such as Beihai and Houhai — were constructed.
The Ming and Qing dynasties that followed expanded the city radically: the Ming redesigned it as an imperial capital in 1421, built the Forbidden City as the emperor's residence, laid out the central north-south axis, and surrounded the city with walls and monumental gates. The Qing added Tibetan temples such as the Lama Temple, expanded the imperial gardens of Beihai and Jingshan, and consolidated Beijing as the political, religious, and cultural heart of the Chinese empire — leaving an urban and symbolic legacy still visible today in every stone and every tree of the city.