By the 10th century, the area was ruled by the
Kingdom of Khotan and
Shule Kingdom when the first
Turkic began migrating into the area. The Saka Kings were still culturally-influenced by the Buddhist homeland of current Nepal, with their rulers adopting
Sanskrit names and titles. The rulers of Khotan grew anxious of hostilities with Turkish khanates, as evidenced by the Mogao grottoes, were they commissioned painting number of divine figures along with themselves. By the time the
Uyghurs and the
Kara-Khanids invaded, Khotan was the only state in the area that had not come under Turkic rule. The Kara-Khanids formed from several Turkic groups that had increasingly settled portions of the Kashgar area. The tribes are thought to have converted to Islam following the conversion of
Sultan Satuq Bughra Khan in 934. Khotan conquered Kashgar in 970, after which a long war ensued between Khotan and the Kara-Khanids. The Karakhanids fought Khotan until sometime before 1006 when the Kingdom was conquered by Yusuf Qadir Khan. The attacks likely related to Khotanese requests for aid when China. Relations with China factored heavily in the war. In 970, after the Khotanese capture of Kashgar, an elephant was sent as tribute by Khotan to Song dynasty China. After the Qara Khanid Turkic Muslims defeated the Khotanese under Yusuf Qadir Khan at or before 1006, China received a tribute mission in 1009 from the Muslims. Following the war, a Buddhist revival occurred in the
Tangut Empire, located in contemporary
Western Xia, following the attacks on the Buddhist states in the region. The Empire became a safe haven for Indian Buddhist monks who were attacked and forced to flee to Tangut.
Legacy Many of the Muslim soldiers who died fighting the region's Buddhist kingdoms are regarded as
martyrs (
shehit), and are visited by pilgrims at shrines called
mazar. For instance, the killing of the martyr Imam Asim led to his grave being worshiped in a massive annual ceremony called the
Imam Asim Khan festival. According to Michael Dillon, the conquest of the region is still recalled in the forms of the Imam Asim Sufi shrine celebration. Taẕkirah is literature written about Sufi Muslim saints in
Altishahr. Written sometime in the period from 1700 to 1849, the Eastern Turkic language (modern Uyghur)
Taẕkirah of the Four Sacrificed Imams provides an account of the Muslim Kara-Khanid war against the Khotanese Buddhists. The
Taẕkirah uses the story of the Four Imams as a device to frame the chronicle, the Four Imams being a group of Islamic scholars from Mada'in city (possibly in modern-day Iraq), who travelled to help the Islamic conquest of Khotan, Yarkand, and Kashgar by the Kara-Khanid leader Yusuf Qadir Khan. The legend of the conquest of Khotan is also given in the hagiology known as the Tazkirat or "Chronicles of Boghra". Extracts from the Tazkiratu'l-Bughra on the Muslim war against the Khotan was translated by
Robert Barkley Shaw. Contemporary poems and attitudes are recorded in the dictionary of the Turkic lexicographer
Mahmud al-Kashgari and in the text
Hudud al-'Alam. Kashgari's dictionary contains disparaging references to Buddhists. The antagonistic attitude towards
Dharmic religions is striking in comparison to several earlier Islamic texts that portrayed Buddhism in a more charitable light, such as the works of
Yahya ibn Khalid. Elverskog states that the attitudes in
Hudud al-'Alam are dissonant, containing both accurate and libelous descriptions of Khotanese Buddhists (including a claim that the Khotanese are cannibals). He argues that these accounts were a way to dehumanize the residents of Khotan and encourage the conquest of the region. The iconoclastic fervor is captured by a poem or folk song recorded in
Mahmud al-Kashgari's Turkic dictionary. Robert Dankoff believes the poem refers to the Qarakhanids' conquest Khotan's despite the text's claim that it refers to an attack on the
Uyghur Khaganate. ==Chagatai incursions==