The Song Empire suffered a disastrous military defeat at the hands of invading Jurchens from the north in 1127 during the Jin–Song wars. Following the Jingkang Incident, the remnants of the Song court were forced to flee south from Kaifeng and establish a new capital at Hangzhou. The loss of northern territory and shifting of the capital marks the division of the dynasty into two distinct periods: the Northern Song (960–1127) and the Southern Song (1127–1279). The Southern Song developed a new navy to combat the Jurchen's Jin dynasty formed in the north. The Song dynasty was able to defeat further Jurchen invasions and even fought the Jin dynasty in an erstwhile alliance with the Mongols. However, the Mongol rulers Genghis Khan, Ögedei Khan, Möngke Khan, and finally Kublai Khan gradually conquered China, until the fall of the final Song emperor at the Battle of Yamen in 1279.