The Chanyuan Treaty () was signed between the Northern Song dynasty and the Liao dynasty in 1005, and marked a pivotal point in Chinese history and in the relations between the two dynasties. The treaty laid the foundation for approximately a century of relative peace between the two major powers, which lasted until the Alliance Conducted at Sea was formed between the Northern Song dynasty and the Jin dynasty in the early 12th century. The diplomatic framework itself which set the peace would continue to be emulated throughout East Asia until the establishment of the Mongol Empire in the 13th century.
Liao–Song relations
Early on from the succession of the Song dynasty from the Five Dynasties in 960, relations between the Song and Liao were cordial. The Song had more important matters on their hand, namely conquering the remaining kingdoms in the south and north. After unifying the south in 979, the Song turned their eyes on the Liao. The Song destroyed the Northern Han state in 979. The Northern Han was a Shatuo Turk kingdom that considered itself the legitimate successor of the Later Han dynasty that fell in 950. As it was under the protection of the Liao, it engendered some friction between the two. However, what concerned the Song even more was the continued Liao possession of the strategic Sixteen Prefectures, which included present-day Beijing.
After the Northern Han was destroyed by the Song, the emperor decided to march on Liao holdings in the Sixteen Prefectures. The Song forces were routed and the emperor had to retreat in ignominy.
The Song once again tried in 986, this time trying to take advantage of the fact that a boy emperor occupied the Liao throne. The Song advanced on the Sixteen Prefectures in three columns. However, the Liao won decisive victories on all three fronts, and diplomatic relations were soon resumed. Emperor Zhenzong succeeded to the Song throne in 997. Throughout the decade, relations between the Song and Liao worsened. In 999, the Liao Emperor Shengzong commenced annual attacks against the Song. Each of these attacks won victories, but no significant change occurred until 1004.
Liao invasion
Emperor Shengzong decided to launch an imperial expedition against the Song personally in the summer of 1004. He took Khitan cavalry and encamped about one hundred miles (160 kilometers) north of the Song capital of Kaifeng. Reluctantly, Emperor Zhenzong marched northward to meet the Liao at Chanyuan. He decided upon Chanyuan because it was the first large city across from the Yellow River. The emperor believed that crossing the Yellow River in an imperial expedition would have great symbolic and psychological value. The Song began to worry that the expedition was not safe for the emperor because the Khitan forces were making serious advances in Hebei Circuit. To protect Chanyuan, Kou Zhun, the lead planner of the Song expedition, had implemented defensive measures such as trenches, but these defenses were already weakened after heavy fighting, resulting in many thousands of casualties, including many generals. The arrival of the emperor raised the Song troops' morale while ensuring that the ensuing battle would be everlastingly famous.
A Song giant crossbow killed the Liao Khitan leader Xiao Dalin in battle in January 1005. This led to despair among the Khitan and crippled their contribution to the offensive.
Peace negotiations
From January 13 to January 18, 1005, the two sides worked out a peace treaty. Some sources say this was in 1004 because of evidence that it happened prior to the New Year on the Chinese lunar calendar. While the Liao initially sought a territorial concession in Guannan, this demand was eventually abandoned. The terms of the treaty included:
The Song would give the Liao an annual tribute of 200,000 bolts of raw silk and 100,000 taels of silver. The State Finance Commission were to deliver these tributes to Hsiung-chou. Civilians and the military would abide by the present territorial boundaries. Neither side would give robbers or bandits who had fled arrest. Neither the north nor the south would grant licenses to sow or reap furrowed fields. All moats and walls already in existence could be kept up but no new ones could be established. Neither side would make requests outside of this treaty.
Afterward, the two imperial families recognized their equal status by addressing one another in familiar terms. For example, the Liao Emperor addressed the Song Emperor as "elder brother", while the Song Emperor addressed the Liao Empress Dowager as "aunt".