The city was the southern capital of the Northern Song dynasty under the name Nanjing. Shangqiu was the first in a series of temporary capitals that the Song Dynasty government moved to during their retreat from the north, when most of northern China had been conquered by the Jurchens in the Jin–Song wars. The Song court had retreated south to the city from their original capital in Kaifeng, after it was captured by the Jurchens in the Jingkang Incident of 1127. The court moved to Shangqiu because of its historical importance to Emperor Taizu of Song, the founder of the dynasty, who had previously served in the city as a military governor. The symbolism of the city was meant to secure the political legitimacy of the new Emperor Gaozong, who was crowned emperor of China in Shangqiu on June 12, 1127. The capital was again moved in 1128 to Yangzhou, and finally to Hangzhou in 1129.