Xinjiang 新疆, literally "new borderlands", was in the 18th century a term used for the newly conquered territories in Eastern Turkestan and the southwestern borderlands in the provinces of Sichuan, Guizhou and Yunnan. Yet from the 1800s on it was exclusively used for Eastern Turkestan, the modern so-called Autonomous Region of the Uyghurs in Xinjiang (Xinjiang Weiwuer zizhiqu 新疆維吾爾自治區).
The ancient name for Eastern Turkestan was "Western Territories". These were conquered and colonized during the Han 漢 (206 BCE-220 CE) and Tang 唐 (618-907) periods. After the end of the Tang period the Western Territories became the settlement of the Turkish people of the Uyghurs - hence the name Turkestan - , as well as other, related people like the Kirgizes, Tajiks, Kazakhs, Mongols and Sibe.
The most important religion of Turkestan is Islam that by and by expelled Buddhism, Manicheism and Nestorianism, the religions in the many city states of the Tarim Basin (see Silk Road) and among the nomad tribes in the north.
Eastern Turkestan was divided by the Tianshan Range 天山 that separated the Tarim Basin from Dzungaria. The Tarim Basin in the south is flanked by the Kunlun Range 昆侖山, the northern part of Tibet. Dzungaria is an open plane flanked by the Tianshan Range in the south, the Altai Range in the east and Lake Balkhash (in modern Kazakhstan) in the west. During the Han period the Dzungar Basin was roamed by the Xiongnu 匈奴 and the Wusun 烏孫, and included the city states of Cheshi 車師. The Han empire set up the protectorate of the Western Territories (Xiyu duhufu 西域都護府), and the Tang empire established the protectorate of Beiting 北庭 in the north and that of the Pacified West (Anxi duhufu 安西都護府) in the south.
The Mongols, who founded the Yuan dynasty 元 (1279-1368) in China, set up the states of Beš Baliq 別失八里 and Almaliq 阿力麻里 (modern Huocheng 霍城, Xinjiang). During the Ming period 明 (1368-1644) Beš Baliq divided into the states Ili Baliq 亦力把里 and Turfan 吐魯番. Turfan, controlling the northern part of Eastern Turkestan, and Khotan (old name Yutian 于闐), the most important polity in the south, were vassals of the Ming empire and delivered tributes to China.
In the early Qing period 清 (1644-1911) the northern part was occupied by the Western Mongol tribes of the Oirat 厄魯特 federation, and in the south, the strongest state was Yarkant (old name Shache 莎車). The most powerful tribe of the Oirats, the Dzungars 準噶爾, rebelled against the suzerainty of the Qing empire. Over several generations the Dzungar khans Galdan and Amursana challenged Qing authority, but they were finally defeated in 1758. Shortly after the local leaders of Yarkant, the Greater and the Lesser Khoja, rebelled. They were defeated in 1759.
The Qing government installed in 1759 a military governor (zongtong jiangjun 總統將軍) in Huiyuan 惠遠 (near modern Huocheng 霍城) who was the highest authority of the Qing administration of the "New Territories". All over the region military garrisons of Banner Troops 八旗 or Green Standard Troops 綠營兵 cared for peace. The direct subordinates of the military governor were a commander-in-chief (dutong 都統) residing in Ürümqi 烏魯木齊, and Grand Ministers Consultant (canzan dachen 參贊大臣) in Yili 伊犁 (modern Yining 伊寧) and Tarbahatai 塔爾巴哈台 (modern Tacheng 塔城), as well as a Grand Minister Consultant for the Administration of the Muslim Border Region (zongli Hui-jiang shiwu canzan dachen 總理回疆事務參贊大臣) residing in Kašgar (old name Shule 疏勒) who supervised the Uyghurs in the eight larger cities of the southern part of Xinjiang.
The chieftains of the Mongol, Kazak and Kirgiz tribes acted as magistrates with hereditary title. In 1851 Russia forced Qing China to allow Russian merchants to market on the soil of Xinjiang, in 1864 China had to cede a great part of northwestern Xinjiang to Russia. During the rebellion of Uighur tribes in the following years, that occupied a large part of Xinjiang, Russia invaded the Yili Basin. It was only in 1881 that China could gain back the city of Yili, but Russia was finally granted important cessions of territory and was allowed to install extraterritorial merchant quarters in the cities of Xinjiang. The suppression of the Muslim rebellion could be finished in 1876. In 1884 the military gouvernement of Xinjiang became province, and the whole territory was regularly administered in prefectures (fu 府), subprefectures (ting 廳), departments (zhou 州), and counties (xian 縣). Only in the region of Yili a military governor was still acting as overseer of the border region.