The state of Shule 疏勒 (Türkic name Kašgar), also called Shale 沙勒, Sute 粟特 (as mother town of the colonies in the Soghdiana) or Qusha 佉沙, covered the area of modern Kashi 喀什, Shule 疏勒, Shufu 疏附, Gashi 伽師, Yengisar 英吉沙, Yuepuhe 岳普河, Atuš 阿圖什, Wuqia 烏恰， Aktao 阿克陶 and Taškurgan 塔什庫爾干. The city of Shule was an important trade spot of the Silk Road where the northern and southern route bypassing the Taklamakan Desert reunited in the west. Shule was also the point from which the Pamir Range has to be crossed in order to reach India or Central Asia. The inhabitants of Shule spoke a language belonging to the Indo-European family.
During the Former Han period 前漢 (206 BCE-8 CE), Shule was inhabited by 18,000 people, living in 1,500 households and able to raise an army of 2,000 men. In 73 CE the king (a-mo-zhi 阿摩支 in the local language) of Qiuci 龜茲, backed by the mighty steppe federation of the Xiongnu 匈奴, killed King Cheng 成 of Shule and enthroned one of his own favourite, Dou-ti 兜題. The latter was in turn captured by the Han general Ban Chao 班超, who at that time resided in Yutian 于闐, and was replaced by King Yu-le 榆勒 (by the Chinese granted the name of Zhong 忠 "the Loyal"). King Zhong supported as leader of auxiliary troops the Han campaign against Gumo 姑墨 in 78 CE. Yet in 84 Zhong rebelled against the domination of the Han empire, in alliance with the king of Shache 莎車 and the leader of the Kangju 康居. Ban Chao occupied Shule, executed King Zhong and enthroned King Cheng-da 成大.
In 91 CE Ban Chao took over the office of Protector-general of the Western Territories (Xiyu duhu 西域都護). He resided in Qiuci, while Xu Gan 徐幹 stayed in Shule as Chief Clerk (zhangshi 長史). King An-guo 安國 drove his uncle Chen-pan 臣槃 into exile in Kushana (Chinese name Guishuang 貴霜, a state in modern Afghanistan). When Anguo died without a heir, Chen-pan's son Yi-fu 遺腹 was enthroned, but Chenpan returned to Shule and dethroned his own son. In 124 CE he supported Chief Clerk Ban Yong 班勇 in the campaign against Cheshi 車師. Shortly later the state of Shache tried to escape the domination of the king of Yutian and sought for the support of Shule and Guishuang. Shule had at that time already a population of 21,000 households.
In 127, King Chen-pan paid tributes to Chang'an 長安 (modern Xi'an 西安, Shaanxi), the capital of the Han empire, and was appointed Grand commander-in-chief (da duwei 大都尉). He led in 132 the punitive campaign against Yutian whose ruler had killed the ruler of Yumi 扜彌. In 168 Chen-pan was killed by his uncle He-de 和德 who was defeated by the armies of the Han empire and gave up further expansion to the east.
During the 3rd century Shule greatly expanded and conquered Zhenzhong 楨中, Shache, Jieshi 竭石, Qusha 渠沙, Xiye 西夜, Yinai 依耐, Manli 滿犁, (Ji)deruo 紀德若, Yuling 榆令, Juandu 捐毒, Xiuxun 休循 (Xiuyou 休脩) and Qin 琴, most of them located in the mountaineous region southwest of Shule.
The king of Shule presented tributes to the court of the Jin empire 晉 (265-420) and was reconfirmed in his title of Commander-in-chief representing the Jin empire. In 437 the tributes were instead brought to the court of the Northern Wei 北魏 (386-534).
During the late 5th century the Yeda 嚈噠 (often translated as "Hephthalites") gained dominance of the region, from the mid-6th century on the Türks (Tujue 突厥). The king of Shule was married to a daughter of the khan of the Western Türks (Xi Tujue 西突厥). Relations to the Tang 唐 (618-907) court were very scarce until 658, when the armies of the Tang defeated the Western Türks under A-shi-na He-lu 阿史那賀魯.
The Tang established the Protectorate of the Pacified West (Anxi duhufu 安西都護府), and Shule was made one of the four defense commands (sizhen 四鎮). Yet the location of this post was very precarious because the Türks were easily able to occupy Shule and make it a base for their raids on Yutian. Only in 675 general Xiao Siye 蕭嗣業 reconquered Shule, that was then made an area command (dudufu 都督府) from which several indirectly governed prefectures (jimizhou 羈縻州) were administered.
In 676 a new power emerged in the area. The armies of the kingdom of Tubo 吐蕃 (Tibet) occupied Shule, and the Tang had to give up this place between 686 and 692. This time the Protector-general of the Tang empire had established military agro-colonies (tuntian 屯田) in Shule to support a larger contingent of troops. Shule became the base of the military operations of the Tang armies into Central Asia and across the Pamir and Hindukush mountain ranges. In 728 Emperor Xuanzong 唐玄宗 (r. 712-755) reconfirmed King Pei An 裴安 in his position as king of Shule. His son Pei Guoliang 裴國良 traveled to Chang'an to present tributes to the Tang empire. With the disintegration of the central government of the Tang after the rebellion of An Lushan 安祿山, Shule was again occupied by the Tibetans in 788.
After the demise of the Tang, Shule stood under the influence of the Türkish federation of the Qarluqs 葛邏祿 and the Uyghurs 回鶻. In the second half of the 10th century, the state of the Karakhans 黑汗 "Black Khans" came into being in Shule (from that time on called Kašgar). Their rulers were adherents of Islam.
In 1041 the Karakhan empire was divided into two parts. The eastern empire in Kašgar controlled the region from Lake Balkhash (in modern Kazakhstan) to the states of Yutian (Khotan) and Qiuci (Kuča) on the Silk Road. In 1130 the empire of Kašgar became subject to the Western Liao 西遼 (Karakhitans, 1124-1218).
The state of Shule was famous for its agricultural products and its textiles that were sold as far as Gaochang 高昌 (modern Turfan). When Chenpan returned from Guishuang be brought with him the religion of Buddhism and introduced it in Shule. Shule became an important centre of Buddhism among the Western Territories, and many monks gathered there, among others the famous translator Kumārajīva 鳩摩羅什. During the Tang period, the monk Huilin 慧琳, a native of Shule, traveled to Chang'an, where he compiled a compound commentary to Buddhist writings, the Yiqiejing yinyi 一切經音義. The Muslim community of Kašgar produced several famous scholars. Abu'l-futūḥ ‘Abd al-Ghāfir ben Ḥusayn al-Alma’ī wrote a history of Kašgar, the Al-Kādjgharī, in Arabian language (lost). Yusūf Khāṣṣ Ḥājib wrote the ballad Kutadgu Bilig in Türkish, and Maḥmūd ibnu 'l-Ḥussayn ibn Muḥammad al-Kāšġarī (shortly called Maḥmūd al-Kāšġarī) wrote the famous Türkish dictionary Dīwānu 'l-luġat at-Turk that was finished in Bagdad.