From around 859 BC the area around modern Taiyuan was occupied by the Rong people. In 662 BC the Rong were driven out by the Beidi people.
During the late Spring and Autumn period Taiyuan became the capital of Zhao. It was constructed by Zhao Jianzi in 497 BC. The city's original name in Zhao was "Jinyang", but it was renamed "Taiyuan" following its conquest by Qin in 228 BC.
During the Later Han dynasty (25-220 AD), Taiyuan was the capital of Bing Province. The city was a secondary capital of the Eastern Wei (534-550) and Northern Qi (550-577) dynasties, during which it grew into a fairly large city and became a center of Buddhism. A new city was built in 562, which was later linked to the old city during the Tang dynasty (618–907), in AD 733.
The dynastic founder of the Tang dynasty, Li Yuan, was from Taiyuan. Li began his conquest of China with Taiyuan as a base, and relied heavily on the support of its local aristocracy. Li's successor, Li Shiming, was also from Taiyuan. The cave temples at Tianlong Mountain, just southwest of the city, were constructed during the mid-to-late Tang dynasty. Taiyuan was periodically designated as the Tang's northern capital and grew into a heavily fortified military base as the dynasty progressed.
The old city was at Taiyuanzhen, a few miles east of the modern city. After the Song dynasty conquered China in 960, Emperor Taizong ordered the old city's destruction, but a new city was set up on the banks of the Fen River in 982. The city became a superior prefecture in 1059 and the administrative capital of Hedong (northern Shanxi) in 1107. It was destroyed by war in 1125, but was rebuilt. It retained its status as provincial capital, with minor changes in its name and status, until the end of the Yuan dynasty (1271-1368). At the beginning of the Ming dynasty (1368–1644) it was renamed "Taiyuan Fu" (府, fu, means "chief town"), and it retained this name until 1912. The city