Before the Eastern Jin the city was known as Jianye, and was the capital of the kingdom of Wu during the Three Kingdoms period.
Renamed Jiankang in 313 CE, it served as the capital of the Eastern Jin and Southern Dynasties, following the retreat from the north due to Xiongnu raids. It rivaled Luoyang in terms of population and commerce and at its height in the sixth century was home to around 1 million people. During the rebellion of Hou Jing, Jiankang was captured in 549 CE after a year-long siege that devastated the city, with most of the population killed or starved to death. During the Sui dynasty national reunification it was almost completely destroyed, and was renamed Jiangzhou (蔣州) and then Danyang Commandery (丹陽郡). Under the Tang dynasty, the city regained its prosperity and the name became Jinling (金陵). By the Five Dynasties and Ten Kingdoms period it was called Jiangning (江寧); in the Southern Song dynasty the name of Jiankang was revived.
When Zhu Yuanzhang founded the Ming dynasty as the Hongwu Emperor in 1368, he made Jiankang the capital of China, renaming it Nanjing "the Southern Capital".
The Tang historian
Xu Song (許嵩, Xǔ Sōng), in his work Jiankang Shilu (建康實錄, Jiànkāng Shílù), coined the term "Six Dynasties" as a mnemonic to mark the various regimes which had centred their power on the site:
In the 6th century, Jiankang became the largest city in the world, with a population of probably more than 1 million people. This was compared to contemporaneous Rome (less than 100,000 after a peak of nearly 1 million), Constantinople (500,000 at the beginning of the reign of Justinian I), Luoyang (over 500,000), and the devastated Chang'an.