The Jin–Song Wars were a series of conflicts between the Jurchen-led Jin dynasty (1115–1234) and the Han-led Song dynasty (960–1279). In 1115, Jurchen tribes rebelled against their overlords, the Khitan-led Liao dynasty (916–1125), and declared the formation of the Jin. Allying with the Song against their common enemy the Liao dynasty, the Jin promised to cede to the Song the Sixteen Prefectures that had fallen under Liao control since 938. The Song agreed but the Jin's quick defeat of the Liao combined with Song military failures made the Jin reluctant to cede territory. After a series of negotiations that embittered both sides, the Jurchens attacked the Song in 1125, dispatching one army to Taiyuan and the other to Bianjing (modern Kaifeng), the Song capital. During the Song's northern expedition to the Liao, the Song general Tong Guan removed the long established defensive forest on the Song-Liao border for the troops to pass. This move exposed the vulnerable ground of the North China Plain to the north, which eventually facilitated the Jin invasion.Surprised by news of an invasion, Song general Tong Guan retreated from Taiyuan, which was besieged and later captured. As the second Jin army approached the capital, Song emperor Huizong abdicated and fled south. Qinzong, his eldest son, was enthroned. The Jin dynasty laid siege to Kaifeng in 1126, but Qinzong negotiated their retreat from the capital by agreeing to a large annual indemnity. Qinzong reneged on the deal and ordered Song forces to defend the prefectures instead of fortifying the capital. The Jin resumed war and again besieged Kaifeng in 1127. They captured Qinzong, many members of the imperial family and high officials of the Song imperial court in an event known as the Jingkang Incident. This separated north and south China between Jin and Song. Remnants of the Song imperial family retreated to southern China and, after brief stays in several temporary capitals, eventually relocated to Lin'an (modern Hangzhou). The retreat divided the dynasty into two distinct periods, Northern Song and Southern Song.
The Jurchens tried to conquer southern China in the 1130s but were bogged down by a pro-Song insurgency in the north and a counteroffensive by Song generals, including Yue Fei and Han Shizhong. The Song generals regained some territories but retreated on the orders of Southern Song emperor Gaozong, who supported a peaceful resolution to the war. The Treaty of Shaoxing (1142) set the boundary of the two empires along the Huai River, but conflicts between the two dynasties continued until the fall of Jin in 1234. A war against the Song begun by the 4th Jin emperor, Wanyan Liang, was unsuccessful. He lost the Battle of Caishi (1161) and was later assassinated by his own disaffected officers. An invasion of Jin territory motivated by Song revanchism (1206–1208) was also unsuccessful. A decade later, Jin launched an abortive military campaign against the Song in 1217 to replace territory they had lost to the invading Mongols. The Song allied with the Mongols in 1233, and in the next year jointly captured Caizhou, the last refuge of the Jin emperor. The Jin dynasty collapsed that year. After the demise of Jin, the Song became a target of the Mongols, and collapsed in 1279.
The wars engendered an era of swift technological, cultural, and demographic changes in China. Battles between the Song and Jin brought about the introduction of various gunpowder weapons. The siege of De'an in 1132 was the first recorded use of the fire lance, an early ancestor of firearms. There were also reports of incendiary huopao or the exploding tiehuopao, incendiary arrows, and other related weapons. In northern China, Jurchens were the ruling minority of an empire predominantly inhabited by former subjects of the Song. Jurchen migrants settled in the conquered territories and assimilated with the local culture. Jin, a conquest dynasty, instituted a centralized imperial bureaucracy modeled on previous Chinese dynasties, basing their legitimacy on Confucian philosophy. Song refugees from the north resettled in southern China. The north was the cultural center of China, and its conquest by Jin diminished the regional stature of the Song dynasty. The Southern Song, however, quickly returned to economic prosperity, and trade with Jin was lucrative despite decades of warfare. Lin'an, the Southern Song capital, expanded into a major city for commerce.