Tang dynasty in Inner Asia

The Tang dynasty in Inner Asia was the expansion of the Tang dynasty's realm in Inner Asia in the 7th and, to a lesser degree, the 8th century AD, in the Tarim Basin (Southern Xinjiang), the Mongolian Plateau, and portions of Central Asia. Wars were fought against the Gokturk Empires and Xueyantuo, but also against many states of Central Asia. This expansion was not steady; for example, the Tang did lose control of the Tarim Basin temporarily to the Tibetan Empire in the 680s, and their expansion north of the Gobi Desert was thwarted in 682. Emperor Taizong's military success was, in part, a consequence of changes he initiated in the Chinese army, including improved weaponry. The emperor placed a new emphasis on cavalry, which was very important because his non-Han opponents used the horse effectively in warfare.
The Tang dynasty was one of the Golden Ages of Chinese history. Coming out of the devastation of the late Sui dynasty, Tang emperors were eager to expand their territories by conquering the Gokturks. As a result, Tang forces mounted several campaigns against the Gokturks in order to subjugate them and consolidated Tang rule in the process. Controlling the Tarim Basin, which contained key trade routes, was also a secondary objective.
The Eastern Gokturks were the primary threat to the Tang dynasty. Following Liang Shidu's defeat and death, the Tang dynasty prepared to march against the Eastern Gokturks. In 630, the Tang army marched against the Gokturks and defeated them in Southern Mongolia, sending them to flight. However, the real victory came when Li Jing, regarded as one of the best generals in Chinese history, surprised the Eastern Gokturk Khan with a fast force of 3,000 Cavalry at the battle of Ying shan, which also involved a rear guard of over 100,000 Tang troops. This battle destroyed the Gokturk army, resulting in the capture of the Khan and over 120,000 Gokturks. Thus ended the Eastern Gokturk Empire. Emperor Taizong of Tang took up the title of Tian Kehan, or "Heavenly Khan" of the Gokturks.
Xueyantuo had helped Tang armies defeat the Eastern Gokturks, but after the demise of the Eastern Gokturks, Xueyantuo-Tang relations turned hostile because Xueyantuo kept on making attacks on Gokturks who were now Tang subjects.
In 642, Taizong sent an army to attack Xueyantuo and destroyed it.
The Western Gokturks were not an initial threat to the Tang, so initially relations were peaceful. However, Civil war and dispute in the Western Gokturks gave the Tang the opportunity to expand into Central Asia. From 642 to 645, the Tang army defeated the Western Gokturks and drove them out of Dzungaria.
In 657, the Tang defeated the last Western Gokturk Khan and took over all Western Gokturk territory.
In what has been described as "a response to a surge of something like national sentiment", the Eastern Türkish Kaghanate was restored in 682 by Elterish (a.k.a. Qutlugh). In the Orkhon inscriptions, Elterish's son describes the modest beginnings of Elterish's struggle against the Tang thus:
The new Khanate was centered on the upper Orkhon river and in the Ötükän, presumably the Khangai mountains. After decades of war and border raids with the Tang, peace was made in 721–22. The second Gokturk Khanate remained a tributary and vassal of the Tang dynasty. It then survived until the 740s, when it fell due to internal conflicts and was succeeded by the Uighur Kaghanate.
The Battle of Talas was a military engagement between the Abbasid Caliphate and their ally, the Tibetan Empire, against the Tang dynasty under Emperor Xuanzong. In July 751 AD, Tang and Abbasid forces met in the valley of the Talas River to vie for control of the Syr Darya region of central Asia. After a stalemate in several days of combat, the Tang lost the battle because the Karluks defected from the Tang side to the Abbasid. The battle is seen by some people as the end of Tang expansion however most scholars agree that the tang continued to expand westward even after the battle.
In 755, the Tang dynasty was subject to the devastating Anshi Rebellion and lost much influence in Inner Asia, which came to be dominated by the Uyghurs. Tang influence and rule over the northwestern regions, however, continued until the dynasty's fall in 907, at which time these areas were taken over by the Tanguts, who later established the Western Xia dynasty in 1038.
Although they now controlled most of the Mongolian Plateau, the Uyghur Khans still maintained relatively cordial relations with the Tang dynasty, accepting many titles from the Tang emperors. in 788, the Uyghur Khan pleaded the Tang emperor to change the title of the Uyghurs from Huihe (回紇) to Huihu (回鶻).
By the mid-800's, the power of the Uyghur Khanate was on the wane. Attacked on all sides, the Uyghurs retreated to the Xinjiang area and their Khanate collapsed, being replaced by the Yenisei Kyrgyz.