In 1779, the third Panchen Lama, a cosmopolitan priest fluent also in Hindi and Persian and well disposed to both Catholic missionaries in Tibet and British East India Company agents in India, was invited to Peking for the celebrations of the Emperor's 70th birthday. In the final stages of his visit, after instructing the Emperor, he contracted smallpox and died in Beijing. The following year, the 8th Dalai Lama assumed political power in Tibet. Problematic relations with Nepal led to Gurkha invasions of Tibet, sent by Bahadur Shah, the Regent of Nepal, in 1788 and again in 1791, when Shigatse was occupied and the great Tashilhunpo Monastery, the then seat of the Panchen Lamas, sacked and destroyed.
During the first incursion, the Manchu amban in Lhasa spirited away to safety both the Dalai Lama and the Panchen Lama, but otherwise made no attempt to defend the country, though urgent dispatches to Beijing warned that alien powers had designs on the region, and threatened Manchu interests. A Qing army found that the Nepalese forces had melted away, and no suppression was necessary. After a renewed incursion in 1791, another army of Manchu and Mongols forces supplemented by strong contingents of Tibetan soldiers (10,000 of 13,000) supplied by local chieftains, repelled this second invasion and pursued the Gurkhas to the Kathmandu Valley. Nepal conceded defeat and returned all the treasure they had plundered. The Qianlong emperor was disappointed with the results of his 1751 decree and the performance of the ambans. A sweeping reform contained in the Twenty-Nine Article Imperial Ordinance of 1793, not only enhanced their status, but ordered them to control border inspections, and serve as conduits through which the Dalai Lama and his cabinet were to communicate. The same Ordinance instituted the Golden Urn system.
Tibet was clearly subordinate to the Qing during the period of the 6th and 7th Dalai lamas. But between this time and the beginning of the 19th century, Qing authority over Tibet gradually weakened to the point of being minuscule, or merely symbolic. Chinese historians argue that the ambans' presence was an expression of Chinese sovereignty, while those favouring Tibetan independence claims tend to equate the ambans with ambassadors. The relationship between Tibet and (Qing) China was that of patron and priest and was not based on the subordination of one to the other, according to the Thirteenth Dalai Lama. (The thirteenth Dalai Lama was deposed in 1904, reinstated in 1908 and deposed again in 1910 by the Qing Dynasty government, but these pronouncements were not taken seriously in Lhasa.)