The founding of Beijing can most probably be attributed to the Yellow Emperor, a formidable leader of the surrounding agricultural settlements. As the story goes, 4,000-5,000 years ago the Yellow Emperor fought his arch rival Chiyou in the prefecture of Zhuo and hence the city of Zhuolu (west of present-day Beijing) was born. His successor Emperor Yao built his capital Youdu on the cite where the city of Ji was later established.
Ji was claimed as capital during the Warring States Period (475-221BC) by the victorious Marquis of Yan, and the remains of that old city are believed to lie beneath the busy traffic of today's Guang'anmen (广安门).
In the early 3rd century BC, the all-conquering Emperor of Qin systematically unified China, and named Ji capital of Guangyang Commandery (part of China's first feudal empire). And so it stood, through war and peace, building and rebuilding, for the next 1,000 years to the end of the Tang Dynasty, ad the country's fundamental trade and military stronghold.
The First Emperor of Qin (259-210BC) unified China and commissioned the Great Wall to be built.