|Ahmad Shah Abdali, ca.1840 (made). Place of origin : Punjab. Inscribed in Persian : “Picture of Ahmad Shah King of Turan”. Victoria and Albert Museum|
Ahmad Shah Durrani was attempting to form alliance of Muslim Central Asian Khanates and Kazaks in order to mount military campaign against the Qing expansion into Central Asia. The powerful Muslim ruler was upset at the murder of Muslim saints, the Kashghar Khojas. According to the report of Valikhanov, such Central Asian rulers as Irdana of Khokand and Tashkent, Fadil Bi of Khojent and Uratepe, and a Sultan of the Kazaks, had earlier sent a letter to Ahmad Shah to ask him “to deliver the Muslim world from attack of non-believers”. In the spring of 1763, Afghan troops were deployed in the area between Khokand and Tashkent, and Ahmad shah dispatched letters to many leaders of Islamic countries urging them to join in the holy war. According to Valikhanov this provoked at least one revolt in 1765 in a town called Ush within Kashgharia itself where Muslims had risen with expectation of receiving help from the wider Muslim world.
This plan for a coordinated attack against Qing territory also appears in Russian records. According to their reports , Irdana had sent letter to Kazak sultan, Ablai, notifying him that Ahmad shah’s emissary has arrived in Khokand with a message that Ahmad Shah has agreed to aid Khokand in case of a Qing attack. A merchant from Khojent who visited Orenburg in January 1764 informed the Russians that Ahmad Shah has concentrated one hundred thousand troops to the north of Kandahar in case of war against Qing.The Qing court received similar reports about such military movement in Central Asia.. In Kashghar troops were also ready for expedition against Afghanistan.
Ahmad Shah Abdali was by far the strongest regional force when the Qing conquered eastern Turkistan and his activities received in Beijing close scrutiny. He sent a letter to the Qing court in 1762 demanding it withdraw from Muslim territories, and, when this ultimatum was rejected, began to assemble a huge invasion force. Central Asian and Qing sources agree that in late 1762, Ahmad shah of Afghanistan sent an embassy to Beijing with a letter. The Afghan letter stated that “Maratha khan (probably the Maratha Peshwa) had amassed force of several hundred thousands troops to respond to his own seizure of Delhi. When they heard that he was approaching, however, they fled into the fortress of Panipat. After six month siege, Ahmad shah defeated them, killing over a hundred thousand.”…This had overtones of a veiled threat.
The Afghan envoy refused to perform Kowtow (kneel and touch the ground with the forehead in worship or submission as part of Chinese custom) .Of all the Muslim envoys who went to court at this time, only the Afghans appear to have refused to kowtow. Court officials angrily reprimanded the Afghan envoy, pointing out that even the Westerners and Russians had performed kowtow . The Qianlong emperor dispatched a letter to Afghan ruler instructing him on folly of war with the reminder that he, the Qainlong emperor, is “lord of all under heaven who watches over every thing inside and outside the empire, and who rewards good and punishes evil”.
Ahmad Shah Abdali massed his troops and corresponded with other Central Asian rulers to raise a united resistance. These efforts came to naught when Qing appeared content to stop at Pamirs. But Ahmad shah , in alliance with Bukhara, invaded Badakhshan, killing its ruler Sultan Shah for betraying two Khoja brothers Burhan-ud-din and Khoja Jahan  to the Qing and dispatched his head to the Qing authorities in Xinjiang.
The Afghan envoy to Beijing presented the Qing emperor with four splendid horses. Milanese Jesuit missionary artist Giuseppe Castiglione (Lang Shinin in pinyin) painted the horses for the Qing emperor by the in the 18th century. The original paintings of the Afghan steeds are kept at the National Palace Museum in Taiwan .
The illustration of Giuseppe Castiglione devoted to”Aiwuhan” is accompanied by a fairly long textual annotation. Portions of it are given below ;
“The Khan, Aihamotesha [Ahmad Shah], lives in the walled city of Kandahar. Aiwuhan is surrounded by mountains on all sides. It is full of rich fields. The people engage in agriculture. Local residents build their own houses and live spread out from each other. There is no record of a census having been made.[…..]..Among the Hui tribes they have long been declared powerful and prosperous. Recently again they annexed a neighboring tribe, Hindustan. They are growing bigger and stronger. In the twelfth month of the twenty-seventh year of the Qianlong emperor’s reign (1763) , looking up to [the emperor’s] majesty and virtue , Aihamotesha [Ahmad Shah] sent the envoy Hezhuomierhan with tribute horses. Their letter to the emperor was respectfully written on gold paper , and it had to be translated by the Siyiguan.[….]..The region produces good horses. The four horses of their tribute are all seven Chi (three Chi are equal to 100 cm) tall and eight Chi long. 
Notes and References:
1. Khoja, a Persian word literally meaning ‘master’, was used in Central Asia as a title of the descendants of the noted Central Asian Naqshbandi Sufi teacher, Ahmad Kasani (1461–1542) or others in the Naqshbandi intellectual lineage prior to Baha al-din Naqshband. The most powerful religious figure in the late Timurid era was the Naqshbandi Shaykh Khwaja Ahrar. The Khojas often played, or aspired to play, ruling roles in the Altishahr or present day region of Tarim Basin in Xinjiang, China.
2. Holy War in China: The Muslim Rebellion and State in Chinese Central Asia by Hodong Kim, page-20-21.
3. The Empire And the Khanate: A Political History of Qing Relations with With Khoqand C1760-1860 By L. J. Newby , page-35
4. From Frontier Policy to Foreign Policy: The Question of India and the Transformation of Geopolitics in Qing China by Matthew Mosca, page-75
5. Beurdeley , Giuseppe Castiglione, p.120-2, 167-8
6. Kneel and touch the ground with the forehead in worship or submission as part of Chinese custom.
7. The Empire And the Khanate: A Political History of Qing Relations With Khoqand C1760-1860 by L. J. Newby, page-35
8 .The two brothers rebelled against their Oirat and subsequently Qing dynasty Chinese overlords. But were eventually driven out of the region to Badakhshan where the ruler Sultan Shah killed them both. Kashghar was annexed as an integral part of the Chinese Empire under the Provincial Governor of Ili (region around Ili River)
9. Eurasian Crossroads: A History of Xinjiang – James A. Millward, page.109-110
10. Managing Frontiers in Qing China: The Lifanyuan and Libu Revisited, pp-209-210