The western borders "jut out" because the Tang dynasty defeated the Western Turks and the city-states of the Tarim Basin (what is now southern Xinjiang). Under Emperor Taizong, the Tang pursued a divide-and-conquer policy that they called yi yi zhi yi ("using barbarians to control barbarians"). They destabilized the Western Turkic confederation by recognizing competing claimants such as Isbara yabghu Qaghan in 641 and I-p'i shih-kuei in 642 and encouraging infighting between tribes among the Western Turks.
As the Western Turkic empire declined, the Tang dynasty was able to expand its control over the oasis kingdoms of the Tarim Basin. The oasis kingdoms were important to the Tang because Silk Road merchants traveled through these oases from Persia, Central Asia, and the Byzantine empire in order to enter China. Karakhoja was annexed by the Tang in 640, Karashahr in 644, and Kucha in 648. Additionally, Kashgar and Khotan submitted to Tang rule in 632 and Yarkand in 635. By 649, Kucha was established as the seat of Anxi-protectorate general.
Chinese military garrisons were stationed in Kucha, Khotan, Kashgar, and Karashahr to supervise Tang control of the Tarim Basin. In 657, Chinese forces and their Uyghur allies defeated and captured the last qaghan of the Western Turks, ending the confederation. With the collapse of the Western Turkic confederation, their territory came under Tang suzerainty. The Tang emperor installed puppet rulers (Ashina Mishe and Ashina Buzhen) to exert their control.
In the 7th century, the oasis kingdoms ping-ponged between Chinese and Tibetan rule. The Tang dynasty became weakened by a revolt led by a former Tang general, An Lushan. The Tibetan Empire annexed the oasis kingdoms of the Tarim Basin as the Tang withdrew from Central Asia.
The Cambridge History of China, Vol. 3: Sui and T'ang China, 589-906 AD, Part 1 and Jonathan Karam Skaff's Sui-Tang China and Its Turko-Mongol Neighbors: Culture, Power, and Connections, 580-800