Karasahr or Karashar (), which was originally known in the Tocharian languages as Ārśi (or Arshi), Qarašähär, or Agni or the Chinese derivative Yanqi (), is an ancient town on the Silk Road and the capital of Yanqi Hui Autonomous County in the Bayingolin Mongol Autonomous Prefecture, Xinjiang.
it had a population of 29,000, growing to 31,773 people in 2006; 16,032 persons of which were Han, 7781 people Hui, 7154 people Uyghur, 628 Mongol and 178 other ethnicities and an agricultural population of 1078 people.
The town has a strategic location, being located on the Kaidu River (known in ancient times as the Liusha), China National Highway 314 and the Southern Xinjiang Railway and is an important material distribution center and regional business hub. The town administers ten communities.
Ārśi was bordered by related Tocharian cultures, many of which also spoke related languages: Kuča (or Kucha), Gumo (later Aksu) to the west, Turfan (Turpan) to the east and to the south, Krorän (Loulan).
In China, Han dynasty sources describe Yanqi (Ārśi / Agni) as a relatively large and important neighboring kingdom. According to Book of Han, the various states of the "Western Regions", including Yanqi, were controlled by the nomadic Xiongnu, but later came under the influence of the Han dynasty, following a Han show of force against Dayuan (Fergana) in the late 2nd century BCE.
thumb|350px|The Tarim Basin in the 3rd century, showing the so-called Tocharian and related states.
From the 1st century BCE onwards, many populations in the Tarim Basin, including the Ārśi underwent conversion to Buddhism and, consequently, linguistic influence from Indo-Iranian languages, such as Pali, Sanskrit, Bactrian, Gandhari and Khotanese (Saka). The city of Ārśi became commonly known as Agni, almost certainly derived from the Sanskrit अग्नि "fire". Names such as Agnideśa (अग्निदेश) and Agni-visaya, both of which are Sanskrit for "city of fire", are also recorded in Buddhist scriptures.
thumb|Soldiers from Karasahr, 8th century CE
According to the Book of the Later Han, General Ban Chao went on a punitive campaign against Yanqi in 94 CE after they attacked and killed the Protector General Chen Mu and Vice Commandant Guo Xun in 75 CE. The king of Yanqi was decapitated and his head displayed in the capital. Later rebellions were subdued by Ban Chao's son Ban Yong in 127 CE.
:It has "15,000 households, 52,000 individuals, and more than 20,000 men able to bear arms. It has high mountains on all four sides. There are hazardous passes on the route to Qiuci (Kucha) that are easy to defend. The water of a lake winds between the four mountains, and surrounds the town for more than 30 li [12.5 km]."
Agnideśa became a tributary state of Tang China in 632 CE. In 644, during the Tang expansion into the Tarim Basin, Emperor Taizong of Tang launched a military campaign against Yanqi after the kingdom allied itself with the Turks. The Four Garrisons of Anxi was established with one based at Yanqi.
According to Book of Zhou (636 CE) the kingdom of Yanqi (Karashahr) was a small country with poor people and nine walled towns, and described the country and their custom thus:
: Marriage is about the same as among the Chinese. All the deceased are cremated and then buried. They wear mourning for seven full days, after which they put it off. The adult men all trim their hair to make a head decoration. Their written characters are the same as those of India.
:
: It is their custom to serve "Heavenly God(s)" but they also show reverence and trust in the doctrines of the Buddha. They especially celebrate these days: The eighth day of the second month, and the eighth day of the fourth month. All the country abstains and does penance according to the teachings of Śākya, and follows His Way.
:
: The climate is cold, and the land good and fertile. For cereals, they have rice, millet, pulse, wheat, and barley. For animals, they have camels, horses, cows, and sheep. They raise silk-worms but do not make silk, merely using [the silk fiber] for padding. It is their custom to relish grape wine, and also to love music. It is some ten li north of a body of water, and has an abundance of fish, salt, and rushes. In the fourth year of the period Pao-ting, its king sent an envoy to present its renowned horses.
thumb|Turkish dignitaries visiting king [[Varkhuman in Samarkand. One of them is labeled as coming from Argi (Karashahr in modern Xinjiang). Afrasiab mural, probably painted between 648 and 651 CE.]]
By the mid-9th century, the area had been conquered by the Uyghur Khaganate and the Tocharian languages were fading from use. Agnideśa became widely known by the Uyghur Turkic name Karasahr (or Karashar), meaning "black city". The influence of Islam grew, while older religions such as Buddhism and Manichaenism declined.
Between the mid-13th century and the 18th century, Karasahr was part of the Mongol Chagatai Khanate.
Karashahr may have been known to late medieval Europeans as Cialis, Chalis, or Chialis, although Korla, Krorän, and other city names are instead favored by some scholars.
In the early 17th century, the Portuguese Jesuit lay brother Bento de Góis visited the Tarim Basin on his way from India to China (via Kabul and Kashgar). De Góis and his traveling companions spent several months in the "Kingdom of Cialis", while crossing it with a caravan of Kashgarian merchants (ostensibly, tribute bearers) on their way to Ming China. The travelers stayed in Cialis City for three months in 1605, and then continued, via Turpan and Hami (all parts of the "Kingdom of Cialis", according to de Góis), to the Ming border at Jiayuguan.
