Guiyi Circuit

The Guiyi Circuit, also known as the Guiyi Army (, 848–1036 AD), was a regional regime nominally subordinate to the Chinese Tang dynasty and later on the Northern Song dynasty. The Guiyi Circuit was controlled by the Zhang family from the second half of the 8th century to the 10th century and then the Cao family until the 11th century. The Guiyi Circuit was headquartered in Shazhou (沙州) (modern Dunhuang).
Background.
The Hexi Corridor was an important part of the Silk Road, connecting Central Asia with Northwest China. After the An Lushan Rebellion, the Hexi Corridor was occupied by the Tibetan Empire. Around the 770s or the 780s, Shazhou, otherwise known as Dunhuang, was occupied by the Tibetans.
Zhang family.
After some 60 years of Tibetan rule, Tibet entered its Era of Fragmentation and was torn by civil war by 851.
In 848 Zhang Yichao, a resident of Shazhou, led an uprising and captured Shazhou and Guazhou from the Tibetans.
By 850 Zhang had captured Ganzhou, Suzhou, and Yizhou. Zhang claimed the title of acting prefect of Shazhou and submitted a petition to Emperor Xuānzong of Tang, offering his loyalty and submission.
In 851 Zhang captured Xizhou (Gaochang). Envoys from Shazhou reached the Tang court and the emperor responded by naming Zhang's territory the Guiyi Circuit and made Zhang Yichao the Guiyi Jiedushi (歸義節度使, Governor of the Guiyi Circuit) and Cao Yijin his secretary general.
In 856 Zhang attacked the Tibetans and defeated them.
By 861 the Guiyi Circuit had extended its authority to Guazhou, Ganzhou, Suzhou, Yizhou, Lanzhou, Shanzhou, Hezhou, Minzhou, Liangzhou, and Kuozhou.
In 866 Zhang Yichao defeated the Tibetan general bLon Khrom brZhe (Baönhom Barzé ) and seized Luntai (Ürümqi) and Tingzhou. However they were immediately captured by the Kingdom of Qocho afterwards. Xizhou (Gaochang) was also captured by the Uyghurs.
In 867 Zhang Yichao departed for the Tang court after his brother Yitan died. His nephew Zhang Huaishen succeeded him as Guiyi Jiedushi.
In 869 the Kingdom of Qocho (Xizhou Uyghurs) attacked the Guiyi Circuit but was repelled.
In 870 the Kingdom of Qocho attacked the Guiyi Circuit but was repelled.
In 872 Zhang Yichao died at court.
In 876 the Kingdom of Qocho seized Yizhou.
Around the years 881 and 882, Ganzhou and Liangzhou slipped from the control of the Guiyi Circuit. The Ganzhou Uyghur Kingdom would establish itself in Ganzhou by 894. In Liangzhou the Tibetan state of Xiliangfu established itself by 906.
In 890 Zhang Huaishen was assassinated and his cousin Zhang Huaiding succeeded him.
In 892 Zhang Huaiding died and left his son in the care of Suo Xun (索勳), son-in-law of Zhang Yichao. Suo Xun declared himself Guiyi Jiedushi.
In 894 Suo Xun was killed by a local aristocrat by the name of Li Mingzhen and Zhang Yichao's daughter. Li's sons shared control of Guiyi Circuit afterwards.
In 896 Li Mingzhen's sons were ousted and Zhang Chengfeng (張承奉), a grandson of Zhang Yichao, became jiedushi.
In 910 Zhang Chengfeng received news of the Tang dynasty's demise and declared himself Emperor Baiyi. The Guiyi Circuit was renamed Kingdom of Jinshan.
Kingdom of Jinshan.
In 910 Zhang Chengfeng established a kingdom known as the Xihan Jinshan (西漢金山國 "Xīhàn Jīnshānguó"), "The Golden Mountain Kingdom of the Western Han," and gave himself the title of "Son of Heaven." This was followed by an invasion by the Ganzhou Uyghurs.
In 911 the Ganzhou Uyghurs attacked again and the Kingdom of Jinshan was forced to become a lesser partner in an alliance with the Ganzhou Uyghurs. The Great Chancellor (大宰相) and the elders of Jinshan State made a treaty with the Ganzhou Uyghurs, recognizing their superiority. The relationship between the two was prescribed as
        ""...the Khan is the father, and the Son of Heaven is the son..." (...可汗是父,天子是子...)"
In 914 Cao Yijin usurped the throne and abolished the kingdom, reverting the name to Guiyi Army.
Cao family.
In 914 Cao Yijin (曹議金) usurped the throne and restored the Guiyi Circuit.
In 916 Cao Yijin married a Ganzhou Uyghur princess and sent delegations to the Later Liang.
In 924 the Ganzhou Uyghur Khagan died and his successors Renmei and Diyin declared war on each other, with Diyin coming out victorious.
In 925 Cao Yijin defeated the Ganzhou Uyghurs.
In 926, Diyin died, and Aduoyu (阿咄欲) became the Khan of the Ganzhou Uyghurs. Aduoyu married a daughter of Cao Yijin.
Kingdom of Guiyi.
In 931 Cao Yijin declared Guiyi a kingdom.
In 934 Cao Yijin married his daughter to the king of Khotan.
In 935 Cao Yijin died and was succeeded by his son, Cao Yuande.
In 939 Cao Yuande (曹元德) died and was succeeded by his brother Yuanshen (曹元深).
In 944 Cao Yuanshen died and his brother Yuanzhong (曹元忠) succeeded him. Cao Yuanzhong's reign was characterized by progress in agriculture, transportation, and printing. Relationship with the Ganzhou Uyghurs remained relatively stable during this period.
In 950 the first depiction of fire lances appeared in Shazhou.
In 974 Cao Yuanzhong died and his nephew Cao Yangong (曹延恭) succeeded him.
In 976 Cao Yangong died and his brother Yanlu (曹延祿) succeeded him.
In 1002 Cao Yanlu's nephew Cao Zongshou rebelled in Shazhou. Cao Yanlu and his brother Cao Yanrui (曹延瑞) committed suicide. Cao Zongshou became ruler of Guiyi.
In 1014 Cao Zongshou died and his son Cao Xianshun (曹賢順) succeeded him.
In 1028 the Tanguts defeated the Ganzhou Uyghurs.
In 1030 Cao Xianshun surrendered to the Tanguts.
In 1036 the Tanguts, who later established the Western Xia, annexed the Kingdom of Guiyi.
Sogdians of Dunhuang.
During the Tang and subsequent Five Dynasties and Song Dynasty, large communities of Sogdians lived in China, especially in the multicultural "entrepôt" of Dunhuang, Gansu, a major center of Buddhist learning and home to the Buddhist Mogao Caves. While the region occasionally fell under the rule of different states (the Tang, the Tibetan Empire, and later the Western Xia led by the Tanguts), it retained its multilingual nature as evidenced by an abundance of manuscripts (religious and secular) in Chinese and Tibetan, but also Sogdian, Khotanese (another Eastern Iranian language native to the region), Uyghur, and Sanskrit.
From the Chinese surnames listed in the Tang-era Dunhuang manuscript Pelliot chinois 3319V (containing the following text: 石定信右全石丑子石定奴福延福全保昌張丑子李千子李定信), the names of the Nine Zhaowu Clans (昭武九姓), the prominent ethnic Sogdian families of China, have been deduced. Of these the most common Sogdian surname throughout China was Shi (i.e. 石), whereas the surnames Shi (i.e. 史), An, Mi (i.e. 米), Kang, Cao, and He appear frequently in Dunhuang manuscripts and registers. The influence of Sinicized and multilingual Sogdians during this "Guiyijun" (歸義軍) period (c. 850 - c. 1000 AD) of Dunhuang is evident in a large number of manuscripts written in Chinese characters from left to right instead of vertically, mirroring the direction of how the Sogdian alphabet is read. Sogdians of Dunhuang also commonly formed and joined lay associations among their local communities, convening at Sogdian-owned taverns in scheduled meetings mentioned in their epistolary letters.