|History of the Turkic peoples pre–14th century|
|Khazar Khaganate 618–1048|
|Kangar union 659–750|
|Turk Shahi 665-850|
|Türgesh Khaganate 699–766|
|Kimek confederation 743–1035|
|Uyghur Khaganate 744–840|
|Oghuz Yabgu State 750–1055|
|Karluk Yabgu State 756–940|
|Kara-Khanid Khanate 840–1212|
|Ganzhou Uyghur Kingdom 848–1036|
|Pecheneg Khanates 860–1091|
|Ghaznavid Empire 963–1186|
|Seljuk Empire 1037–1194|
|Cuman–Kipchak confederation 1067–1239|
|Khwarazmian Empire 1077–1231|
|Kerait Khanate 11th century–13th century|
|Delhi Sultanate 1206–1526|
|Qarlughid Kingdom 1224–1266|
|Golden Horde 1240s–1502|
|Mamluk Sultanate (Cairo) 1250–1517|
The military of the Tang Dynasty was staffed with a large population of Turkic soldiers, referred to as Tujue in Chinese sources. Tang elites in northern China were familiar with Turkic culture, a factor that contributed to the Tang acceptance of Turkic recruits. The Tang emperor Taizong adopted the title of "Heavenly Kaghan" and promoted a cosmopolitan empire. Turkic soldiers that served under the Tang dynasty originated from the Eastern Turkic Khaganate. It began with Tang dynasty Emperor Taizong who sent his general Li Jing, eventually ended in defeating the Eastern Turks and capturing their leader Jiali Khan. Taizong regularly recruited and promoted military officers of Turkic ancestry, whose steppe experience contributed to the western and northern expansion of the Tang empire. The Turkic general Ashina She'er participated in the Tang capture of the Karakhoja, Karasahr, and Kucha kingdoms in Xinjiang. The half-Turkic general An Lushan started a revolt that led to the decline of Tang Dynasty.
The Orkhon inscriptions by the Gokturks were critical of the Turks that had served the Tang Dynasty, and condemned them for helping the Chinese emperor expand his burgeoning empire. The Turkic soldiers stationed by the Chinese in the Tang garrisons of Central Asia settled in the region, spreading Turkic languages in an area that had been predominantly Indo-European.
The empire of the Tang Dynasty was more cosmopolitan and diverse than the earlier Han Dynasty. The Tang Dynasty elites of northern China had an interest in Turkic culture and intermingled with the people of the steppes. The setting of one Tang poem describes a yurt, and the performance of a Turkic actress was hosted in the emperor's palace  Following the Tang Dynasty's defeat of the Eastern Turkic Khaganate, the government authorized the settlement of Turks along the borders of the Tang empire. Turkic officers of the former khaganate were recruited as generals in the Tang military, and their experience with steppe warfare contributed to the Tang's military successes as it expanded westward.
Emperor Taizong, also known by his personal name Li Shimin, was familiar with the culture of the steppe nomads and employed military strategies using steppe tactics as a prince. Taizong was a skilled horseman, and during a celebration of his victory and ascension to the throne, sacrificed a horse in a ritual derived from a Turkic religious practice. He was able to outmaneuver the heavy cavalry of the Sui Dynasty with his light cavalry, a characteristic of steppe warfare. Taizong shared personal relationships with Turkic allies as a prince, reinforced through oaths sworn as blood brothers. His later successes as an emperor against the armies of Central Asia through diplomacy and divide and rule are the result of his early experiences with Turkic culture.
Taizong's adoption of the Heavenly Kaghan title was used to legitimize his role as a steppe khan not solely as a Chinese emperor with the title of Son of Heaven. He valued the kaghan title and was sincere about his role as a leader of Central Asia. He sought to solidify his claim as a kaghan by organizing a gathering of Turkic leaders in the Lingzhou fortress during the last years of his reign to reconfirm his title.
While mostly symbolic, the title of Heavenly Kaghan shows Taizong's open attitudes towards the existence of a multicultural and ethnically diverse Tang empire. Taizong was proud of his policies promoting ethnic equality, and was reported to have said that, "The emperors since ancient times have all appreciated the Chinese and depreciated the barbarians. Only I view them as equal. That is why they look upon me as their parent."
He had a paternalistic attitude towards his subjects and believed that it was his duty to treat the Chinese and foreign ethnic groups as equals under one ruler. Taizong's views grew into state policy as his government recruited Turkic and other non-Han Chinese soldiers into the Tang military. Turkic soldiers were later promoted to higher ranks as commanders and generals. The surname of Li, belonging to the royal family of Li Shimin, was awarded to Han and non-Han officers for their service.
Tang relationship with the Turks may have further deepened had the crown prince Li Chengqian, a Turkophile, been enthroned as Taizong's successor. Li Chengqian enthusiastically embraced Turkic customs, and Chinese historian Sima Guang recorded that he:
"He [Chengqian] lved to emulate Turkish speech and their manner of dress. He chose from among his retinue those who had Turkish features and grouped them in bands of five; he made them plait their hair, wear sheepskins, and herd sheep. He had made five wolf's head banners and tents and set up yurts. The crown prince took up residence here; he gathered sheep and cooked them, and then, drawing out his waist-knife, he would carve the meat and let everyone eat."
Chengqian was deposed as crown prince by Taizong after his plans to usurp the throne were revealed. He was exiled by Taizong and died as a commoner.
Main article: Tang dynasty in Inner Asia
Turkic generals led many of the Tang Dynasty military campaigns that expanded the dynasty's territorial reach into Central Asia. In total, ten Turks were able to reach the highest military position of general. Ashina She'er, formerly the ruler of Beshbaliq and Kharakhoja between 630 and 635 and a member of the Ashina clan, was recruited as a Tang general in 635. He fought as a commander in a successful campaign against Karakhoja in 640. She'er was chosen as the general for the military expedition against Karasahr. The Tang loyalist that had been installed as ruler after the first invasion of Karasahr in 644 by Chinese general Guo Xiaoke was deposed by his cousin in a revolt. The usurper was executed after the rebellion was suppressed, and Tang governance returned to the oasis state. She'er continued onward to the nearby kingdom of Kucha, a state that had supported Karasahr during its war against the Tang.
Emperor Taizong himself tended to the injuries of the Turkic Generals Qibi Heli and Ashina Simo, who were both wounded during the campaign against Goguryeo.
Ashina Zhong, the brother of She'er, also served as a Turkic general of the Tang Dynasty, and was a participant in a military performance hosted by Emperor Gaozong in 655. Another Turkic member of the Ashina clan, Ashina Helu, briefly served as a commander of the Tang army in Gansu before his rise as a kaghan of the Western Turkic Khaganate. During his reign, the Turkic tribes were unified under a single leader. Emperor Gaozong, Taizong's successor, dispatched a military expedition in 657 against Helu, who had been raiding Tang settlements. The campaign was led by the general Su Dingfang and the Turkic commanders Ashina Mishe and Ashina Buzhen, who were opposed to Helu. Helu was defeated and captured by the Tang forces, and the territories annexed from the Western Turks were placed under Tang governance through the Anxi Protectorate.
Gaozong awarded the military service of the Turkic commanders Mishe and Buzhen by appointing them as proxy rulers of ten Western Turkic tribes. The ten tribes were split between the two cousins, and the western half was given to Buzhen while Mishe controlled the eastern tribes. In 685, the sons of Mishe and Buzhen were sent from the Tang capital of Chang'an, where they resided, to succeed their fathers in the west. Neither lasted long as Turkic rulers; one was overthrown by his tribal subjects and the other was deposed by the Second Turkic Khaganate after an invasion in 690.
An Lushan was a Tang general of mixed Turkic and Soghdian ancestry whose revolt between 755 and 763, the An Shi Rebellion, devastated the Tang Dynasty. Unlike the majority of Turkic military officers, An Lushan served the Tang as an official closely involved with the politics of the imperial court, rather than as a general in a garrison on the Tang frontier. The dynasty might have collapsed had it not been for their alliance with the Uyghur Turks. The rebellion diminished the Tang enthusiasm for cosmopolitanism that was a characteristic of the dynasty's earlier years.
The Orkhon inscriptions, a memorial erected by the Turks, lamented the Tang influence on the Turks and the Turkic adoption of Chinese titles:
"The Turkish people let their state.... go to ruin... their sons worthy of becoming lords became slaves, and their daughters worthy of becoming ladies became servants to the Chinese people. The Turkish lords abandoned their Turkish titles. Those lords who were in China held the Chinese titles and obeyed the Chinese emperor and gave their service to him for fifty years. For the benefit of the Chinese, they went on campaigns up to [the land of] the Bukli qaghan in the east, where the sun rises, and as far as the Iron Gate in the West. For the benefit of the Chinese emperor they conquered countries."
The inscriptions, made to commemorate the elites of the Second Turkic Empire, stress the importance of loyalty between a kaghan and the ruler's subjects. The Turks that sided with the Tang are condemned, and the disunity of the Turkic tribes is blamed on a lack of respect for the authority of the kaghan.
The Turkic soldiers and generals that worked in the Chinese garrisons of Central Asia spurred Turkic migration into the area. The Turkic language and culture of the Tang soldiers there gradually displaced the indigenous Indo-European languages. The native languages of Sogdian and Tokharian disappeared as the Turkic languages spread in the Tarim Basin.
The Tang Dynasty declined after the An Shi Rebellion, and the dynasty eventually fell in 907. During the Five Dynasties and Ten Kingdoms period, an era of upheaval following the dynasty's collapse, many of the kingdoms in China were ruled by families of Turkic ancestry. The Shatuo Turks founded the Later Tang in 923, the Later Jin in 936, and the Later Han in 947. Eventually, the Han Chinese Song Dynasty conquered all the Shatuo Turks, uniting all the states once again.