Heqin, also known as marriage alliance, refers to the historical practice of Chinese monarchs marrying princesses — usually members of minor branches of the ruling family — to rulers of neighboring states.

Lou Jing, the author of the policy, proposed granting the eldest daughter of Emperor Gaozu of Han to Modu Chanyu of the Xiongnu. His proposal was adopted and implemented with a treaty in 198BC, following the Battle of Baideng two years prior. Wang Zhaojun of the Han dynasty and Princess Wencheng of the Tang dynasty are among the most famous heqin princesses.

Han dynasty There were a total of fifteen instances of heqin marriage alliances during the Han dynasty.

The Han dynasty sent random unrelated commoner women falsely labeled as "princesses" and members of the Han imperial family multiple times when they were practicing Heqin marriage alliances with the Xiongnu in order to avoid sending the emperor's daughters. 200BC: Emperor Gaozu of Han marries a Han "princess" to Xiongnu chieftain Modu Chanyu. This is the first recorded incidence of heqin in Chinese history. 192BC: Emperor Hui of Han marries another Han "princess" to Xiongnu chieftain Modu Chanyu. 176BC: Emperor Wen of Han marries a third Han "princess" to Xiongnu chieftain Modu Chanyu. 174BC: Emperor Wen of Han marries a Han "princess" to Xiongnu chieftain Laoshang Chanyu. She brings a Yan eunuch named Zhonghang Yue with her to be her tutor. 162BC: Emperor Wen of Han marries another Han "princess" to Xiongnu chieftain Laoshang Chanyu. 160BC: Emperor Wen of Han marries a Han "princess" to Xiongnu chieftain Gunchen Chanyu. 156BC: Emperor Jing of Han marries another Han "princess" to Xiongnu chieftain Gunchen Chanyu. 155BC: Emperor Jing of Han marries a third Han "princess" to Xiongnu chieftain Gunchen Chanyu. 152BC: Emperor Jing of Han marries a fourth Han "princess" to Xiongnu chieftain Gunchen Chanyu. 140BC: Emperor Wu of Han marries a Han "princess" to Xiongnu chieftain Gunchen Chanyu. 108BC: Emperor Wu of Han marries Liu Xijun (刘细君 130–101 BC), daughter of Liu Jian (刘建), Prince of Jiangdu (江都王 d. 121 BC), granddaughter of Prince Yi of Jiangdu, to Liejiaomi, King of Wusun. 103BC: Emperor Wu of Han marries Liu Jieyou (刘解忧 121–49 BC) to King Junxumi of Wusun (Liejiaomi's grandson). After Junxumi's death in 93BC, Princess Jieyou, in accordance with Wusun tradition, married his successor (and younger brother), King Wengguimi. After Wengguimi's death in 60BC, Princess Jieyou again remarried his successor King Nimi (son of Junximi and a Xiongnu princess). 33BC: Emperor Yuan of Han marries Wang Zhaojun (王昭君 52 BC – 15), a lady of the imperial harem, to Xiongnu chieftain Huhanye. After Huhanye's death in 31BC, she remarried Huhanye's successor (his son by his first wife and thus her stepson) Fuzhuleiruodi Chanyu.

Xiongnu The Xiongnu practiced marriage alliances with Han dynasty officers and officials by marrying off daughters of the Chanyu (the Xiongnu ruler) to Han people who joined the Xiongnu and Xiongnu in Han service. The daughter of the Laoshang Chanyu (and older sister of Junchen Chanyu and Yizhixie Chanyu) was married to the Xiongnu General Zhao Xin, the Marquis of Xi who was serving the Han dynasty. The daughter of the Qiedihou Chanyu was married to the Han general Li Ling after he surrendered and defected. The Yenisei Kirghiz Khagans claimed descent from Li Ling. Another Han general who defected to the Xiongnu was Li Guangli who also married a daughter of the Hulugu Chanyu. The Han diplomat Su Wu married a Xiongnu woman given by Li Ling when he was arrested and taken captive. The Han explorer Zhang Qian married a Xiongnu woman and had a child with her when he was taken captive by the Xiongnu. The Emperor Wu of Han dispatched Zhang Qian to explore the Western Regions and to form an alliance with the Yuezhi people in order to combat the Xiongnu. During this time Zhang married a Xiongnu wife, who bore him a son, and gained the trust of the Xiongnu leader.

The Yenisei Kyrgyz khagans of the Yenisei Kyrgyz Khaganate claimed descent from the Han general Li Ling, grandson of the famous general Li Guang. Li Ling was captured by the Xiongnu and defected in the first century BCE. Since the Tang imperial Li family also claimed descent from Li Guang, the Kirghiz Khagan was therefore recognized as a member of the Tang imperial family. This relationship soothed the relationship when Kyrgyz khagan Are (阿熱) invaded Uyghur Khaganate and put Qasar Qaghan to the sword; the news was brought to Chang'an by Kyrgyz ambassador Zhuwu Hesu (註吾合素). Ban Zhi married a Xiongnu Jin royal woman from the Xiutu royal family.

Kingdom of Khotan

The Cao family of ethnic Han descent that ruled the Guiyi Circuit established marriage alliances with the Saka Kingdom of Khotan, with both the Cao rulers marrying Khotanese princesses and with Cao princesses marrying Khotan rulers. A Khotan princess who was the daughter of the King of Khotan married Cao Yanlu.

Sixteen Kingdoms During the Sixteen Kingdoms period, there were a total of six recorded instances of heqin marriage. Heqin marriage alliances during the Sixteen Kingdoms period differed from those practiced during the Han dynasty in two main ways. First, they involved "real" princesses (i.e. daughters of emperors or rulers). Second, unlike during the Han dynasty, when most heqin marriages were aimed at establishing peace with foreign nations, heqin marriages during the Sixteen Kingdoms period were made primarily to settle rivalries and maintain a balance of power between the various states in China at the time.

Fu Jian (337–385), Emperor Xuanzhao of Former Qin, married one of his daughters to Yang Ding, ruler of the state of Chouchi. Fu Deng, Emperor Gao of Former Qin, married his younger sister, Princess Dongping (东平公主) to Qifu Gangui, Prince of Western Qi. 441: Feng Ba, Emperor Wencheng of Northern Yan, married his daughter, Princess Lelang (乐浪公主), to Yujiulü Hulü, Khan Aidougai of Rouran. 415: Yao Xing, Emperor Wenhuan of Later Qin, married his daughter, Princess Xiping (西平公主), to Emperor Mingyuan of Northern Wei. Because she was unable to forge a golden statue with her own hands, she was never formally empress, but was nevertheless recognized and respected as Emperor Mingyuan's wife, Consort Yao. Qifu Chipan, Prince Wenzhao of Western Qin, married his daughter, Princess Xingping (兴平公主), to Juqu Mengxun, Prince of Northern Liang's son Juqu Xingguo. 433: Juqu Mengxun, Prince of Northern Liang, marries his daughter, Princess Xingping (兴平公主), to Emperor Taiwu of Northern Wei. She became Emperor Taiwu's concubine.

Northern and Southern dynasties During the Northern and Southern dynasties period, China was divided into many rival states. A complicated system of rivalries and vassalage existed. Heqin marriage was employed as a method to maintain a balance of power or to solidify alliances between states.

During the Northern and Southern dynasties, there were five instances of heqin marriage. 428: Emperor Mingyuan of Northern Wei marries his daughter, Princess Shiping (始平公主), to Helian Chang, Emperor of Xia. 437: Emperor Mingyuan of Northern Wei marries his daughter, Princess Wuwei (武威公主), to Juqu Mujian, Prince Ai of Hexi, last ruler of the state of Northern Liang, whence she is known as Princess Tuoba. Princess Lanling (兰陵公主), a princess of the imperial family of Northern Wei, married the Khagan of the Rouran Khaganate, Yujiulü Anagui. Princess Qianjin (千金公主), daughter of Yuwen Zhao, Prince of Zhao (赵王宇文招) and a member of the imperial family of Northern Zhou, married Ishbara, Khagan of the Eastern Turkic Khaganate. 582: Emperor Ming of Western Liang marries his daughter, Princess Xiao, to Yang Guang, Prince of Jin, the second son Emperor Ming's overlord, Emperor Wen of Sui. She is known as Empress Xiao of Sui after his accession to the throne as Emperor Yang of Sui.

Northern Wei The Tuoba imperial family of the Xianbei-led Northern Wei dynasty started to arrange for ethnic Han elites to marry daughters of the imperial family in the 480s. More than fifty percent of Tuoba Xianbei princesses of the Northern Wei were married to southern Han men from the imperial families and aristocrats from southern China of the Southern dynasties who defected and moved north to join the Northern Wei. Some exiled royalty of Han descent fled from southern China and defected to the Northern Wei. Several daughters of the Xianbei Emperor Xiaowen of Northern Wei were married to ethnic Han elites, the Liu Song royal Liu Hui 刘辉, married Princess Lanling 蘭陵公主 of the Northern Wei,. Princess Huayang 華陽公主 to Sima Fei 司馬朏, a descendant of Jin dynasty (266–420) royalty, Princess Jinan 濟南公主 to Lu Daoqian 盧道虔, Princess Nanyang 南阳长公主 to Xiao Baoyin 萧宝夤, a member of Southern Qi royalty. Emperor Xiaozhuang of Northern Wei's sisters, the Shouyang Princess was wedded to the Liang dynasty ruler Emperor Wu of Liang's son Xiao Zong 蕭綜. One of Emperor Xiaowu of Northern Wei's sister was married to Zhang Huan, an ethnic Han, according to the Book of Zhou. His name is given as Zhang Xin in the Book of Northern Qi and History of the Northern Dynasties which mention his marriage to a Xianbei princess of Wei. His personal name was changed due to a naming taboo on the emperor's name. He was the son of Zhang Qiong.

When the Eastern Jin dynasty ended Northern Wei received the Jin prince Sima Chuzhi (司馬楚之) as a refugee. A Northern Wei Princess married Sima Chuzhi, giving birth to Sima Jinlong. Northern Liang Lushuihu King Juqu Mujian's daughter married Sima Jinlong.

Rouran The Rouran Khaganate arranged for one of their princesses, Khagan Yujiulü Anagui's daughter Princess Ruru 蠕蠕公主 to be married to the ethnic Han regent Gao Huan of the Eastern Wei.Gao Huan, as demanded by Yujiulü Anagui as one of the peace terms between Eastern Wei and Rouran, married the Princess Ruru in 545, and had her take the place of Princess Lou as his wife, but never formally divorced Princess Lou. After Gao Huan's death, pursuant to Rouran customs, the Princess Ruru became married to Gao Huan's son Gao Cheng, who also, however, did not formally divorce his wife.

Gaochang The Kingdom of Gaochang was made out of ethnic Han colonists and ruled by the Han people Qu family, which originated from Gansu. Jincheng commandery (金城 in Lanzhou), district of Yuzhong (榆中) was the home of the Qu Jia. The Qu family was linked by marriage alliances to the Turks, with a Turk being the grandmother of King Qu Boya's.

Sui dynasty With the establishment of the Sui dynasty in 581, much of China proper was once again unified under one dynasty. Heqin marriage during the Sui dynasty therefore returned to its original purpose of trying to appease barbarian tribes surrounding the Sui. There were a total of seven instances of heqin marriage during the Sui dynasty. 597: Emperor Wen of Sui marries Princess Anyi (安义公主), a Sui "princess", to Yami Qaghan, Khagan of the Eastern Turkic Khaganate. She was assassinated by Yung Yu- lu in 599 599: Emperor Wen of Sui marries another Sui princess, Princess Yicheng (义成公主), the daughter of a Sui imperial clansman, to Yami, Khagan of the Eastern Turkic Khaganate. After his death in 609, Princess Yicheng, in accordance with the Göktürk custom of levirate marriage, remarried to Yami Qaghan's successor and son (by another wife), Shibi Qaghan. After Shibi Qaghan's death in 619, Princess Yicheng again remarried to Shibi Qaghan's successor and younger brother, Chuluo. After the khagan's death in 621, Princess Yicheng remarried for the fourth and final time to his successor and younger brother, Illig Qaghan, who revolted against Tang China and was captured and killed in 630 Emperor Yang of Sui married Princess Xinyi (信义公主), a Sui "princess", to Heshana Khan, Khagan of the Western Turkish Khaganate. Emperor Yang of Sui married his youngest daughter, Princess Huainan (淮南公主), to the new heir, Shibi's eldest son, Tuli.