During the first decade of the 16th century, Tseten Dorje, a servant of the Rinpung family, with the help of some local tribes and Mongols, managed to gain control of Shigatse and the surrounding regions of Tsang province. From 1566 to 1642 Tseten Dorje and his two successors ruled Tibet with the title of Depa Tsangpa. Sonam Gyatso, born in 1543, emerged as a scholar of great spiritual and temporal wisdom. He became the spiritual teacher of the Phamo Drugpa ruler, Drakpa Jungne. He was the Abbot of Drepung monastery and the most eminent lama of that time. He provided extensive relief to the Kyichu flood victims in 1562, founded Lithang Monastery in 1580 and Kumbum Monastery in 1582. He also successfully mediated between the various warring factions in Tibet. He converted Altan Khan to Buddhism and the latter conferred on him the title Dalai Lama meaning "Ocean of Wisdom" in 1578. As Sonam Gyatso was third in his line, he became the Third Dalai Lama, the title being posthumously conferred on his two previous incarnations. A close spiritual relationship developed between Tibet and Mongolia. The Gelugpa sect grew stronger and gradually eclipsed the waning Sakya authority. In 1642, the Fifth Dalai Lama, Ngawang Lozang Gyatso, assumed both spiritual and temporal authority over Tibet. He established the present system of the Tibetan Government, known as the Ganden Phodrang, "Victorious Everywhere". After becoming the ruler of all Tibet, he set forth to China to demand Chinese recognition of his sovereignty. The Ming Emperor received the Dalai Lama as an independent sovereign and as an equal. It is recorded that he went out of his capital to meet the Dalai Lama and that he had an inclined pathway built over the city wall so that the Dalai Lama could enter Peking without going through a gate. The Emperor not only accepted the Dalai Lama as an independent sovereign but also as a Divinity on Earth. In return the Dalai Lama used his influence to bring the warlike Mongols into acknowledging the Emperor's sway in China. Henceforth, there started a Priest-Patron relationship which brought a new element into the relations of Tibet, China and Mongolia. Another important event was the statement of the Fifth Dalai Lama that the line of the first Panchen Lama, Choskyi Gyaltsen, who was one of his tutors, would continue. The glorious reign of the Great Fifth was followed by a period of intrigue and instability. To start with, the powerful prime minister, Desi Sangye Gyatso, had kept the death of the Fifth Dalai Lama secret for fifteen years in order to complete the construction of the Potala Palace and also to ward off possible interference from the Manchus, who had become increasingly powerful in China. When the Sixth Dalai Lama, Tsangyang Gyatso, was finally enthroned in 1697 he turned out to be an embarrassment to the Desi and his associates, refusing to take interest in the affairs of state and leading a frivolous life. Circumstances arising from the behavior of the young Dalai Lama and also the personal conflict between the Desi and Lhazang Khan, the grandson of Gusri Khan and the chief of the Qosot Mongols in Central Tibet, led to the resignation of the Desi and the complete take-over of political power by Lhazang Khan, who later allied himself with the Manchus and sent the young Dalai Lama into exile. Lhasang Khan was himself defeated and killed by Dzungar Mongols who had come to Tibet at the invitation of the monks of the three big Gelugpa monasteries in Lhasa. The Dzungars, who were staunch followers of the Gelugpa tradition, were not content with the death of Lhazang Khan. They proceeded to persecute the adherents of the Nyingamapa sect. This brought about a feeling of disenchantment against their presence among sections of the Tibetan people. When Kalsang Gyatso, the reincarnation of the Sixth Dalai Lama, was discovered in Lithang, in eastern Tibet, there was a struggle among various tribes of the Mongols and the Manchus to gain control over him so that they could exercise their influence in Tibet. The Manchus were successful in this endeavor and so it was that in 1720 the Manchus sent in troops to escort the young Dalai Lama and also avenge the death of their ally, Lhazang Khan. At the same time, Tibetan troops under Khangchennas and Pholhanas took advantage of the situation to attack the Dzungars, who fled with as much loot as they could take with them. When the Manchu troops entered Lhasa, the Dzungars hact already left. But they had other designs and when their troops finally left in 1723 they left behind a Resident or Amban ostensibly to serve the Dalai Lama but in fact to look after their own interests. This was the beginning of Manchu interference iri Tibetan affairs. The Manchus also put up their own nominee as the Tibetan Regent against Tibetan wishes. A few years later the Manchu nominee was killed and then the Manchu Emperor, Yung Cheng, sent a military force which was the first time the Manchus invaded Tibet. The Manchu force in 1727 tried to bring changes in the administration of Tibetan Government. The Manchu Emperor also tried to buy the allegiance of certain Tibetan princes, chieftains and lamas by giving many of them seals of office. But the Tibetans regarded the seals as a compliment and did not acknowledge them as a mark of vassalage. However, the Manchu Residents (Ambans) began to meddle in Tibetan state matters whenever the opportunity arose. The Tibetans were repelled by the extent of Manchu intrigues when the Manchu Resident murdered the Tibetan Regent. The Tibetans retaliated by massadring the Manchus in Lhasa. Again the Manchus invaded Tibet in 1749 and they tried in vain to increase the power of the Manchu Resident. In 1786 the Gurkhas invaded Tibet. The cause for this invasion went back a few years before the Gurkhas had gained full control of Nepal. Nepal had started adding copper to the silver coins which they were supplying to Tibet. In 1751 the Seventh Dalai Lama had written to the three Newari Kings, who ruled over the principalities of Kathmandu, Patan and Bhatgaon, to protest against this practice. When Prithvi Narayan, chief of the Gurkhas, overthrew the Newari rulers he was similarly apprised of the situation. Another sore point in the relations between the Gurkhas and the Tibetans had been the intervention of Tibet in the Gurkha invasion of Sikkim. Tibet offered help to Sikkim and a treaty was concluded between Nepal and Sikkim in the presence of two Tibetan representatives. The Gurkhas resented this interference and were looking for an excuse to attack Tibet. Such an opportunity arose in the controversy over the third Panchen Lama's personal property which was being claimed by the Panchen's two brothers, Drugpa Tulku and Shamar Tulku. The latter hoped to use the backing of the Gurkhas for his claim. The Gurkhas used the claim of Shamar Tulku and invaded Tibet.