Yanjing (Chinese: 燕京, also known as Youzhou 幽州, Ji 薊 or Fanyang 范陽 for administrative purposes) was an ancient city and capital of the State of Yan in northern China. It was located in modern Beijing.
Yanjing was founded by State of Yan, whose rulers made it their capital city. After the conquest of Yan by the State of Qin, the city was made the capital of Guangyang commandery (simplified Chinese: 广阳郡; traditional Chinese: 廣陽郡). During the Han Dynasty (206 BCE–220 BCE), the city was renamed Fanyang as the capital of Yuyang commandery (漁陽郡). It was the administrative center of Youzhou at the time of the Eastern Han (25–220 CE). Due to its proximity to the northern border of China, Yanjing was constantly involved in armed contests with various external powers. Further assaults on the city followed during the Yellow Turban Rebellion, which began in 184 CE.
At the time of the Three Kingdoms Period (220–280 CE), the commander of Fanyang was Liu Yan, better known as the governor of Yizhou Province a few years later. After Liu Yan's reposting, Liu Yu became the commander of Yizhou. His subordinate, Gongsun Zan, eventually attacked Youzhou and killed Liu Yu, becoming the commander of Fanyang.
During the Tang Dynasty (618–907 CE) and Later Jin (936–947 CE), Fanyang was an important military garrison and a commercial hub. To the north of the city lay the military region of Yingzhou (营州) with Daizhou (代州) to the west. An Lushan began his revolt in Fanyang, and when he became the Emperor of the Greater Yan, Fanyang was designated its capital.
Under the Liao Dynasty (907-1125), the city was renamed Nanjing (南京) and was the southern capital of Liao. It was also called Yanjing. In the following Jin dynasty (1115–1234), the city was called Zhongdu (中都), the central capital of the Jin. After the Mongols took the city, it was renamed Yanjing. After the Mongols razed it, a new city called Dadu was built adjacent to the former Jin capital which was the capital of the Yuan Dynasty (1279–1368).