AURELIA DOCHNAL considers the conception of foreigners in Tang dynasty China.

(Image: Tang-era statue of a foreigner. Wikimedia Commons)

The Tang dynasty is commonly known to have been a Chinese golden age, a period of vast wealth, cultural richness, and cosmopolitan cultural exchange in Chinese history. Foreigners visited the empire, shared their religious traditions and traded their goods, lending the Tang great prestige and influence in East Asia. However, Tang was also an empire marked by rapid expansion, which inevitably engenders questions about its treatment and conception of foreigners – or, as commonly known, “barbarians,” a fraught word in Chinese history. In order to probe this question and possibly complicate the mainstream notion of Tang as purely a tolerant, welcoming, and multinational empire, I will be exploring the relationship between official Tang legal doctrine and foreigners in Turfan, an oasis city located on the border between China and central Asia. I will focus on a dispute between a Sogdian – or a deceased Sogdian merchant’s younger brother – and his Chinese trading partner. This legal dispute will provide a surprising insight into Chinese-foreign relations during the Tang dynasty, as well as forcing us to examine the legal distinction between native and foreigner.

Turfan, a border city linking the nomadic people of northwest Asia and the oasis-dwellers of Xinjiang, is an unlikely but remarkably important place for the study of medieval Chinese history and the history of law in Tang dynasty China. Unlikely, because the city is located on the outskirts of what was once the Tang’s vast territory, distant from the powerful and sprawling dynastic capital of Chang’an. Turfan was part of the independent Gaochang kingdom (also known as Kharakoja) for almost 200 years.[i] This kingdom was a Han Chinese-governed, Han Chinese-majority area, ruled by the Qu family who maintained a sinicized culture. The official written language was Chinese, students learned the Chinese classics, and the government was based on an imperial bureaucratic structure. The Qu rulers also patronized Buddhism.[ii] We have evidence that residents of Turfan used Chinese characters as early as 273 CE. Because of its high proportion of Chinese inhabitants and this sinicized culture, Turfan was often referred to by Sogdian merchants as “Chinatown.” Turfan was a multinational, mixed city, made up mostly of Sogdians and Chinese.[iii] Its Chineseness became even more firmly cemented after the Tang army defeated the Gaochang empire, invading and taking control of the oasis in 640. From that point forward, Turfan became an annexed Tang territory.[iv]

This annexation meant that the oasis of Turfan was under direct Tang rule, and Tang officials enforced the Tang Code, the first Chinese legal code to survive intact to our times. The Tang dynasty was especially significant in Chinese history due to its establishment of political and cultural supremacy in East Asia, which it achieved partly due to vigorous military expansion in the region. It flourished in the realms of literature and art, as well as becoming a major Buddhist hub thanks to its many monk-pilgrims who left on faraway journeys to bring back Buddhist scriptures. The capital city of Chang’an had more than half a million inhabitants, and, its markets filled with goods and spices from faraway regions, it was the largest and most prestigious city in East Asia.[v] This economic and cultural prosperity was supported by a strongly centralized political system. The empire was divided into prefectures and counties which reported to the central government in Chang’an. The county magistrate was the lowest official in this bureaucracy, and he managed most local matters, like hearing criminal cases and collecting taxes. This is the figure immortalized in numerous Chinese detective stories such as those about Judge Di (a figure inspired by a historical sixth-century Tang dynasty judge and county magistrate named Di Renjie). While the emperor was the head of the government, he relied almost entirely on appointed officials to carry out his laws and govern a just state. These officials were appointed through a series of government examinations, including one in law – although the study of law was not as popular as the study of literature in the Tang dynasty, and only a minority of candidates took on the study of the law.[vi] In distant, newly-conquered provinces, such as that of Turfan, the Tang established what is known as “loose rein” prefectures (jimi zhou 羈縻州). These were administrative structures based on the Chinese government bureaucracy, led by chieftains of the defeated tribes and kingdoms. These prefectures numbered more than eight hundred at the peak of Tang power. To make sure that the new territory was running smoothly, area-commands (dudu fu 都督府) staffed by Chinese officials and backed by Chinese troops were organized in the prefectures.[vii]

While the Tang Code is not the first legal code we know of to have existed in China, it is the only one that survives in its entirety, providing us with a more complete view of Chinese criminal law in the dynastic period. It is made up of two parts: the first section describes the general principles of criminal law, while the second provides concrete examples of applications. Unfortunately, as Wallace Johnson, the Code’s first translator into English and foremost Western scholar, explains, “​​none of the case records of court hearings has survived from the T’ang period.”[viii] We are therefore dearly lacking in sources describing the actual effects of this detailed Code and provided only with its positivist framework. The extant code dates from 737, which is not the original version. The original was completed in 653. Still, the one we can access today is probably very close in content to the original version.[ix]

The Tang empire’s cultural brilliance and stable political organization ensured that people of many nationalities and many professions, ranging from merchants to monks, were attracted to the area and often settled there. In Turfan, a desert oasis city on the border with Iran and central Asia, the foreign population was mostly made up of Sogdians, traders from the easternmost part of the Iranian world.[x] The Turfan trading route connected the regions of Sogdiana with the central trading city of Chang’an. The Sogdian traders often sojourned briefly in Turfan while continuing along their journey, but many also lived there full-time, interacting with local Chinese and even taking Chinese-style names.[xi] When the Tang invaded Turfan in 640, they implemented the equal-field system then enforced throughout the Tang empire – which distributed to inhabitants a certain amount of land, from which they then paid a fixed tax to the emperor – and renamed Turfan Xizhou 西州.[xii] Before the land redistribution, Tang officials took a census of the entire Gaochang kingdom, which came out to almost 40000 residents. One of the most interesting things about this census is that officials did not record the ethnicities or spoken languages of Turfan’s inhabitants, nor did they distinguish between Chinese and non-Chinese residents of the oasis. As Valerie Hansen puts it, this is “an indication that a black-and-white distinction to us was more variegated to the people of the time.”[xiii] The only way that today we can distinguish between Sogdians and ethnically Han people listed in registrars, contracts, and documents is through their distinct names. While Sogdians took Chinese names, they were often transliterated versions of their clan of origin in their native languages.[xiv]

It is significant that Emperor Taizong went to war with the Gaochang kingdom over its decision to block the trade route from central Asia to China that it controlled thanks to its geographical position. Against the advice of his closest advisors, who did not approve of the huge amounts of manpower and expenses associated with conquering and annexing such a faraway area, Taizong deemed it necessary to integrate Turfan into the empire and establish in it a protectorate-general.[xv] This decision demonstrates how important the trading route between central Asia and the Chinese mainland was for the emperor. Beyond being an economic source, open channels of trade between the Tang and the central Asian powers ensured the continuing cultural prestige of the empire.

Upon the conquest of Turfan, officials applied the Tang Code to all its inhabitants. Valerie Hansen describes a case brought by a deceased Sogdian merchant’s younger brother, Cao Rokhshan, against a Chinese merchant, Li Shaojin. We know that the brother was a Sogdian by his name – Cao indicates the part of Sogdiana he hailed from. The case’s affidavits are preserved after having been recycled into paper garments for a deceased person in Turfan’s Astana graveyard. Cao claimed that Li had borrowed 275 bolts of silk (a form of currency) from his elder brother and never paid it back. As Prof. Hansen notes, “this was a small transaction in the Silk Road economy; the Tang government regularly spent much larger amounts.”[xvi] Although neither Cao nor Li lived in Turfan, and both were likely itinerant merchants whose wives and families resided in Chang’an, Cao possibly brought the suit to Turfan because from 670-679 it was the seat of the Anxi Protectorate which then included the Kingdom of Kucha – where his brother had disappeared. He had disappeared while on a trading journey, and a witness speculated that he may have been captured by bandits.

A key part of the suit was the two witnesses – also Sogdian merchants, Cao Guoyi and Cao Bisuo. They had witnessed the original loan and challenged Li’s testimony that he had never received it. They did not have a copy of the original contract for officials to consult. The officials applied Tang law: in Valerie Hansen’s words, “Rokhshan should have had no expectation that the presiding officials would apply Iranian law to his case. He was simply seeking the restitution that he felt was due to him under Chinese law.”[xvii] Under Tang law, which recognized oral testimony and a written contract as equal in legal standing, the Turfan court ruled in Rokhshan’s favor, and ordered Li to pay back the 275 bolts of silk with interest. The remaining documents do not survive, so we do not know if Li complied with the ruling – but it is surprising at first glance that in a case in which three out of four parties were foreigners, a Chinese court should rule in the foreigners’ favor. It is also interesting that a Chinese court should be willing to intervene in personal matters, illustrating the extent of the government’s involvement in its citizens’ daily lives.

Nevertheless, we have few primary sources that can shed light on the way the Tang empire’s vast and efficient bureaucracy dealt with foreigners. With the large influx of Sogdians and other nationalities, it makes sense that the Tang Code would have a section addressing disputes between Tang subjects and foreigners, and foreigners on Tang territory among themselves. The section is quoted below:

“Article 48: ‘Crimes Committed against Each Other by Foreigners’

48.1 All cases involving foreigners of the same nationality who have committed crimes against each other will be sentenced following their own customary law.

48.2 Cases involving those of different nationalities who have committed crimes against each other will be sentenced following Chinese law.

Subcommentary: Foreigners refers to persons of those barbarian countries who have their own rulers and leaders. They each have their own habits and customs and their regulations, and the laws are not alike. In cases involving those of the same nationality who have committed crimes against each other, the court must ask about the regulations in their native country and sentence the offense following their customs and laws. In all cases involving those of different nationalities who have committed crimes against each other, such as one person from Koryo and another person from Paekche [countries in the Korean peninsula], Chinese law will be used to sentence and decide the punishment.”[xviii]

What stands out from this quoted fragment is particularly the use of the word “barbarian.” This term, “hua wai ren 化外人” in the original Chinese (more literally translated as “a person outside the sphere of civilization”), complicates the straightforward picture of the Tang empire as freely accepting and open-mindedly cosmopolitan. Research by scholars about other borderland cities in Tang China, like Adam Fong’s study of foreigners in medieval Guangzhou, demonstrates how, while foreigners lived in separate quarters from Chinese citizens and were not encouraged to intermingle, a “new type of cross-cultural interaction, one of accommodation without syncretism or denigration” was born.[xix] Scholars have long explored the distinction between foreigner and native in Tang dynasty China, and the legal interpretation of Article 48’s “barbarians” is still unclear.[xx] “Foreigner” may have meant a different ethnic group from the Han Chinese, or it may have meant someone whose household was not registered within the empire – in ancient China, territory was governed by household registration.[xxi] Since the Tang Code contains no definition of what makes up a foreigner, and since different areas of the empire had vastly different cultural and economic contexts, it makes sense that these labels could vary between cities. The fact that the 640 Turfan census does not distinguish between Han Chinese and Sogdians living in the city is an interesting insight on the concept of identity in the Tang empire. Turfan was a newly-conquered oasis, part of the Tang emperor Taizong’s plan of “displaying military force and conquering the barbarians,”[xxii] and so it is therefore implied that its residents, even if Chinese by origin, may have been thought of as a sort of barbarian species as well. Perhaps one explanation for the lack of distinction between ethnicities in the census is the unity in this identification as citizens of a conquered state, a mark of Tang expansion and control of trade routes. Considerations of ethnicity and race may have come second to the emperor Taizong’s desire to expand into central Asia and establish outposts governed by Tang officials in those strategic areas.

From the anecdotal historical evidence describing Taizong’s overwhelming aspiration to expand into central Asia, even as his advisors urged him against it, the question of nationality in the border region of Turfan becomes clearer. In the early Tang, expansion was closely linked to government prestige. Turfan was already culturally sinicized, and this was well-known among Sogdian traders, many of whom took Chinese names and integrated into the community – all the while continuing their Zoroastrian practice. The Tang was not the welcoming haven for all foreigners that a modern depiction of it sometimes describes: the other Tang Code law dealing with foreigners – Article 88 – is harsh and exclusionary. Marrying a foreigner, for instance, results in “life exile at a distance of 2,000 li,” and engaging in illegal trade carries severe punishments based on the value of the traded objects.[xxiii] In an international trading community, a primary concern of the Tang government was keeping a suitable distance between the Chinese and foreigners and ensuring that Chinese culture was protected. We can therefore surmise that, in a city like Turfan, which was recently conquered and located in a strategic border position distant from the central empire, different standards of foreignness applied. Ethnicity may not have been the primary defining factor in who was considered a Tang subject, and in a newly annexed territory, these distinctions may not yet have been clear.

That is one explanation for the surprising success of the Sogdian, Cao Rokhshan, in his suit against the Chinese merchant. He was not tried under Iranian law, but Chinese law, as article 48.2 of the Tang Code states, and yet was able to win, even as a non-Chinese. This is remarkable for a medieval trading society, and underlines that while clear divisions and distinctions existed between natives and foreigners in everyday life in Tang China, those boundaries were ever-blurring, left ambiguous even by state law, and welcoming to traders who might need a place to fairly settle disputes. Turfan’s geographical and imperial constitution as an in-between border space mirrors this blurred binary between foreign and local. As goods and people constantly traveled and intermingled along the Silk Road, strictly defining laws were impractical. Flexibility and openness seem to have been the Tang Code’s greatest strength.


Fong, Adam C. 2014. “”Together They Might Make Trouble”: Cross-Cultural Interactions in Tang Dynasty Guangzhou, 618-907 C.E.” Journal of World History 25 (4): 475-492.

Hansen, Valerie. 2005. “The Impact of the Silk Road Trade on a Local Community: The Turfan Oasis, 500-800.” In Les Sogdiens en Chine, edited by Etienne de la Vaissiere and Eric Trombert, 283-310. Paris: Ecole Francaise d’Extreme Orient.

———. 2021. “Silk Road Cities and their Co-Existing Legal Traditions.” In Research Handbook on International Law and Cities, edited by Miha Marcenko, Helmut P. Aust and Janne E. Nijman, 17-28: Edward Elgar Publishing Limited.

———. 2012. The Silk Road: A New History. New York: Oxford University Press.

Johnson, Wallace. 1979. The T’ang Code, Volume I: General Principles. Princeton: Princeton University Press.

———. 1997. The T’ang Code, Volume II: Specific Articles. Princeton: Princeton University Press.

The Editors of Encyclopaedia Britannica. “Turfan, China.”, last modified Nov 14.

Wang Bingjun. 2018. “Tang Lü “Hua Wairen” Tiao De Falü Jieshi [the Legal Interpretation of Tang Law’s “Barbarians”].” Falü Fangfa [Legal Method] 25 (3).

Wang Zhenping. 2009. “Ideas Concerning Diplomacy and Foreign Policy Under the Tang Emperors Gaozu and Taizong.” Academia Sinica 22 (1): 239-285.

Wechsler, Howard J. 1979. “T’ai-Tsung (Reign 626–49) the Consolidator.” In The Cambridge History of China: Sui and T’Ang China, 589–906 AD, Part One, edited by Denis C. Twitchett. Vol. 3, 188-241. Cambridge: Cambridge University Press.


[i] The Editors of Encyclopaedia Britannica, “Turfan, China.”

[ii] Valerie Hansen, The Silk Road: A New History, (Oxford University Press, 2012), 91.

[iii] Ibid, 83.

[iv] Howard J. Wechsler,  “T’ai-tsung (reign 626–49) the consolidator,” in Dennis Twitchett (ed.), The Cambridge History of China, Volume III, (Cambridge University Press), 224-225.

[v] Wallace Johnson, The T’ang Code, Volume I, (Princeton University Press), 3-5.

[vi] Ibid, 4-5.

[vii] Wang Zhenping, “Ideas concerning Diplomacy and Foreign Policy under the Tang Emperors Gaozu and Taizong,” Asia Major, 257.

[viii] Wallace Johnson, The T’ang Code, Volume I, 8.

[ix] Valerie Hansen, “Silk Road cities and their co-existing legal traditions,” 24.

[x] Ibid, 22.

[xi] Ibid, 25.

[xii] Valerie Hansen, “The Impact of the Silk Road Trade on a Local Community: The Turfan Oasis, 500-800,” 286.

[xiii] Ibid.

[xiv] Ibid, 287-290.

[xv] Howard J. Wechsler,  “T’ai-tsung (reign 626–49) the consolidator,” 225-226.

[xvi] Valerie Hansen, “Silk Road cities and their co-existing legal traditions,” 26.

[xvii] Ibid.

[xviii] Wallace Johnson (trans.) quoted in Valerie Hansen, “Silk Road cities and their co-existing legal traditions,” 24-25.

[xix] Adam C. Fong, “‘Together They Might Make Trouble’: Cross-Cultural Interactions in Tang Dynasty Guangzhou, 618-907 C.E.” Journal of World History, 484.

[xx] Wang Bingjun, “Táng lǜ “huà wàirén” tiáo de fǎlǜ jiěshì [The Legal Interpretation of Tang Law’s “Barbarians”],” Fǎlǜ fāngfǎ [Legal Method].

[xxi] Ibid.

[xxii] Jiu Tang Shu 旧唐书 (Old Book of Tang) quoted in Wang Zhenping, “Ideas concerning Diplomacy and Foreign Policy under the Tang Emperors Gaozu and Taizong,” Asia Major, 2009, 257.

[xxiii] Wallace Johnson, The T’ang Code, Volume II, (Princeton University Press), 55.