Traversed by the Silk Road, Xinjiang is the Chinese name for the Tarim and Jungar regions of what is now northwest China. At the beginning of the Han Dynasty (206 BC - 220 AD), the region was subservient to the Xiongnu, a powerful nomadic people based in modern Mongolia. In the 2nd century BC, Han China sent Zhang Qian as an envoy to the states in the region, beginning several decades of struggle between the Xiongnu and Han China over dominance of the region, eventually ending in Chinese success. In 60 BC Han China established the Protectorate of the Western Regions (西域都護府) at Wulei (烏壘; near modern Luntai) to oversee the entire region as far west as the Pamir.During the usurpation of Wang Mang in China, the dependent states of the protectorate rebelled and returned to Xiongnu domination. Over the next century, Han China conducted several expeditions into the region, re-establishing the protectorate from 73 AD to 74, from 91 to 107, and from 123 onward. After the fall of the Han Dynasty (220), the protectorate continued to be maintained by the Wei Dynasty (until 265) and the Western Jin Dynasty (from 265 onwards).

The Western Jin Dynasty succumbed to successive waves of invasions by nomads from the north at the beginning of the 4th century. The short-lived non-Han Chinese kingdoms that ruled northwestern China one after the other, including Former Liang, Former Qin, Later Liang, and Western Liang, all attempted to maintain the protectorate, with varying extents and degrees of success. After the final reunification of northern China under the Northern Wei empire, its protectorate controlled what is now the southeastern third of Xinjiang. Local states such as Shule, Yutian, Guizi and Qiemo controlled the western half, while the central region around Turpan was controlled by Gaochang, remnants of a state (Northern Liang) that once ruled part of what is now Gansu province in northwestern China.

In the late 5th century the Tuyuhun and the Rouran began to encroach upon the region and assert power in southern and northern Xinjiang, respectively, and the Chinese protectorate was lost again. In the 6th century the Turks began to emerge in the Altay region, subservient to the Rouran. Within a century they had defeated the Rouran and established a vast Turk Empire, stretching over most of Central Asia past both the Aral Sea in the west and Lake Baikal in the east. In 583 the Turks split into western and eastern halves, with Xinjiang coming under the western half. In 609, China under the Sui Dynasty defeated the Tuyuhun, gaining control of southeastern
Xinjiang.

The Tang Dynasty was established in 618, and would prove to be one of the most expansionist dynasties in Chinese history. Starting from the 620's and 630's, Tang China conducted a series of expeditions against the Turks, eventually forcing the surrender of the western Turks in 657. Xinjiang was placed under the Anxi Protectorate (安西都護府; "Protectorate Pacifying the West"). The protectorate did not outlast the decline of Tang China in the 8th century. During the devastating Anshi Rebellion, Tibet invaded Tang China on a wide front from Xinjiang to Yunnan, sacking the Tang capital in 763, and taking control of southern Xinjiang by the end of the century. At the same time, the Uyghur Khaganate took control of northern Xinjiang, as well as much of the rest of Central Asia, including Mongolia.Both Tibet and the Uyghur Khaganate declined in the mid-9th century. The region then entered into an age of fragmentation. The Kara-Khanid Khanate was in control of western Xinjiang in the 10th century and the 11th century, while branches of the Uyghurs established themselves in central Xinjiang in the same time period. In 1132, remnants of the Khitan Empire from Manchuria entered Xinjiang, fleeing the onslaught of the Jurchens. They established an exile regime, the Kara-Khitan Khanate, that unified what is now Xinjiang over the next century.

Genghis Khan's Mongol Empire conquered the Kara-Khitan in 1218. After the disintegration of the Mongol Empire, Xinjiang was ruled by the Chagatai Khanate, one of the successor states of the empire. In the 15th century the Chagatai Khanate disintegrated into separate states in Gulja, Yarkand, and Turpan. In the 17th century, the Jüün Ghar (Jungars) established an empire over much of the region. The Qing Empire, established by the Manchus in China, gained control over eastern Xinjiang after defeating the Jungars in 1697. In 1755, the Manchu Empire attacked Gulja, and captured the Jungar khan. Over the next two years, the Manchus destroyed the remnants of the Jungar khanate. In 1759 a rebellion south of the Tian Shan mountains was put down, thus cementing Manchu rule over Xinjiang. The Manchus put the area under the rule of a General of Ili, headquartered at
Gulja.

By the mid-19th century, the Russian Empire was encroaching upon Qing China along its entire northern frontier. In 1864 most of what was northwestern Xinjiang up to Lake Balkhash was ceded to the Russian Empire in the Treaty of Tacheng. This area now constitutes parts of Kazakhstan, Kyrgyzstan, and Tajikistan. Also in 1864, rebellions broke out all over Xinjiang, including Kucha, Khotan, Kashgar, Turpan and other areas. In spring 1865, Yaqub Beg, a lord of the neighbouring Khanate of Kokand, entered Xinjiang via Kashgar, and conquered nearly all of Xinjiang over the next six years. In 1871, Russia seized the Ili River valley, including Gulja. By then, Qing China held onto only a few strongholds, including
Tacheng.

Yaqub Beg's rule lasted until General Zuo Zongtang (also known as General Tso) reconquered the region between 1875 and 1877 for Qing China. In 1881, Qing China recovered the Gulja region. In 1884, Qing China established Xinjiang ("new frontier") as a province, formally applying onto it the political system of China proper.

In 1912 the Qing Dynasty was replaced by the Republic of China. Yuan Dahua, the Qing governor of Xinjiang, acceded to the Republic of China in March of the same year. Following insurgencies against Governor Yang Zengxin in the early 1930s, a rebellion in Kashgar led to the establishment of the short-lived First East Turkistan Republic (1st ETA) in 1933. Xinjiang was eventually brought under the control of Han Chinese warlord Sheng Shicai, who ruled Xinjiang for the next decade. A Second East Turkistan Republic (2nd ETA, also known as the Three Districts Revolution) existed from 1944-1949 with Soviet support in what is now Ili Kazakh Autonomous Prefecture in northern Xinjiang. It ended when the People's Liberation Army (PLA) entered Xinjiang in 1949. According to the PRC interpretation, the 2nd ETA was Xinjiang's revolution, a positive part of the communist revolution in China; the 2nd ETA acceded to and welcomed the PLA when they entered Xinjiang, a process known as the Peaceful Liberation of Xinjiang. However independence advocates view the ETA as an effort to establish an independent state, and the subsequent PLA entry as an invasion. The autonomous region of the PRC was established on October 1, 1955, replacing the province. The PRC's first nuclear test was carried out at Lop Nur, Xinjiang, on October 16, 1964.

There continue to be tensions in the region, centering both upon Uyghur aspirations to independence and resentment towards what is described as repression of non-Han Chinese culture by Amnesty International and Human Rights Watch, and Han Chinese resentment towards the aforementioned Uyghur sentiments, as well as towards PRC policies of ethnic autonomy which are perceived as discriminatory against Han Chinese (see autonomous entities of China). Independence advocates view Chinese rule in Xinjiang, and policies like the Xinjiang Production and Construction Corps as Chinese imperialism. These tensions occasionally result in major incidents and violent clashes, such as the Kazakh Exodus from Xinjiang in 1962, in which 60,000 refugees fled into the Soviet Union; the Baren Township riot on April 5, 1990 that resulted in more than 50 deaths; the Ghulja riot of February 5, 1997, where over 1000 Uyghurs clashed with military police, resulting in anywhere between 10 and 200 deaths; and the Urumqi bus bombs of February 25, 1997 that killed 9 and injured 68.