Question: When did the 5th Dalai Lama gain political control over the country that managed religious and regional political affairs?

full_context: Document 1: Sino-Tibetan relations during the Ming dynasty: Rawski writes that Altan Khan's conversion to the Gelug "can be interpreted as an attempt to expand his authority in his conflict with his nominal superior, Tümen Khan." To further cement the Mongol-Tibetan alliance, the great-grandson of Altan Khan—the 4th Dalai Lama (1589–1616)—was made the fourth Dalai Lama. In 1642, the 5th Dalai Lama (1617–1682) became the first to wield effective political control over Tibet.
Document 2: Sino-Tibetan relations during the Ming dynasty: While the Ming dynasty traded horses with Tibet, it upheld a policy of outlawing border markets in the north, which Laird sees as an effort to punish the Mongols for their raids and to "drive them from the frontiers of China." However, after Altan Khan (1507–1582)—leader of the Tümed Mongols who overthrew the Oirat Mongol confederation's hegemony over the steppes—made peace with the Ming dynasty in 1571, he persuaded the Ming to reopen their border markets in 1573. This provided the Chinese with a new supply of horses that the Mongols had in excess; it was also a relief to the Ming, since they were unable to stop the Mongols from periodic raiding. Laird says that despite the fact that later Mongols believed Altan forced the Ming to view him as an equal, Chinese historians argue that he was simply a loyal Chinese citizen. By 1578, Altan Khan formed a formidable Mongol-Tibetan alliance with the Gelug that the Ming viewed from afar without intervention.
Document 3: Yuan dynasty: There were many religions practiced during the Yuan dynasty, such as Buddhism, Islam, and Christianity. The establishment of the Yuan dynasty had dramatically increased the number of Muslims in China. However, unlike the western khanates, the Yuan dynasty never converted to Islam. Instead, Kublai Khan, the founder of the Yuan dynasty, favored Buddhism, especially the Tibetan variants. As a result, Tibetan Buddhism was established as the de facto state religion. The top-level department and government agency known as the Bureau of Buddhist and Tibetan Affairs (Xuanzheng Yuan) was set up in Khanbaliq (modern Beijing) to supervise Buddhist monks throughout the empire. Since Kublai Khan only esteemed the Sakya sect of Tibetan Buddhism, other religions became less important. He and his successors kept a Sakya Imperial Preceptor (Dishi) at court. Before the end of the Yuan dynasty, 14 leaders of the Sakya sect had held the post of Imperial Preceptor, thereby enjoying special power. Furthermore, Mongol patronage of Buddhism resulted in a number of monuments of Buddhist art. Mongolian Buddhist translations, almost all from Tibetan originals, began on a large scale after 1300. Many Mongols of the upper class such as the Jalayir and the Oronar nobles as well as the emperors also patronized Confucian scholars and institutions. A considerable number of Confucian and Chinese historical works were translated into the Mongolian language.
Document 4: Yuan dynasty: The Central Region, consisting of present-day Hebei, Shandong, Shanxi, the south-eastern part of present-day Inner Mongolia and the Henan areas to the north of the Yellow River, was considered the most important region of the dynasty and directly governed by the Central Secretariat (or Zhongshu Sheng) at Khanbaliq (modern Beijing); similarly, another top-level administrative department called the Bureau of Buddhist and Tibetan Affairs (or Xuanzheng Yuan) held administrative rule over the whole of modern-day Tibet and a part of Sichuan, Qinghai and Kashmir.
Document 5: Sino-Tibetan relations during the Ming dynasty: Nevertheless, the ethno-geographic caste hierarchy favoring the Mongols and other ethnicities were accorded higher status than the Han Chinese majority. Although Han Chinese who were recruited as advisers were often actually more influential than high officials, their status was not as well defined. Kublai also abolished the imperial examinations of China's civil service legacy, which was not reinstated until Ayurbarwada Buyantu Khan's reign (1311–1320). Rossabi writes that Kublai recognized that in order to rule China, "he had to employ Chinese advisors and officials, yet he could not rely totally on Chinese advisers because he had to maintain a delicate balancing act between ruling the sedentary civilization of China and preserving the cultural identity and values of the Mongols." And "in governing China, he was concerned with the interests of his Chinese subjects, but also with exploiting the resources of the empire for his own aggrandizement. His motivations and objectives alternated from one to the other throughout his reign," according to Rossabi. Van Praag writes in The Status of Tibet that the Tibetans and Mongols, on the other hand, upheld a dual system of rule and an interdependent relationship that legitimated the succession of Mongol khans as universal Buddhist rulers, or chakravartin. Van Praag writes that "Tibet remained a unique part of the Empire and was never fully integrated into it," citing examples such as a licensed border market that existed between China and Tibet during the Yuan.
Document 6: Sino-Tibetan relations during the Ming dynasty: The official position of the Ministry of Foreign Affairs of the People's Republic of China is that the Ming implemented a policy of managing Tibet according to conventions and customs, granting titles and setting up administrative organs over Tibet. The State Council Information Office of the People's Republic states that the Ming dynasty's Ü-Tsang Commanding Office governed most areas of Tibet. It also states that while the Ming abolished the policy council set up by the Mongol Yuan to manage local affairs in Tibet and the Mongol system of Imperial Tutors to govern religious affairs, the Ming adopted a policy of bestowing titles upon religious leaders who had submitted to the Ming dynasty. For example, an edict of the Hongwu Emperor in 1373 appointed the Tibetan leader Choskunskyabs as the General of the Ngari Military and Civil Wanhu Office, stating:
Document 7: Sino-Tibetan relations during the Ming dynasty: Starting in 1236, the Mongol prince Kublai, who later ruled as Khagan from 1260–1294, was granted a large appanage in North China by his superior, Ögedei Khan. Karma Pakshi, 2nd Karmapa Lama (1203–1283)—the head lama of the Karma Kagyu lineage of Tibetan Buddhism—rejected Kublai's invitation, so instead Kublai invited Drogön Chögyal Phagpa (1235–1280), successor and nephew of Sakya Pandita, who came to his court in 1253. Kublai instituted a unique relationship with the Phagpa lama, which recognized Kublai as a superior sovereign in political affairs and the Phagpa lama as the senior instructor to Kublai in religious affairs. Kublai also made Drogön Chögyal Phagpa the director of the government agency known as the Bureau of Buddhist and Tibetan Affairs and the ruling priest-king of Tibet, which comprised thirteen different states ruled by myriarchies.
Document 8: Tibet: The 5th Dalai Lama is known for unifying the Tibetan heartland under the control of the Gelug school of Tibetan Buddhism, after defeating the rival Kagyu and Jonang sects and the secular ruler, the Tsangpa prince, in a prolonged civil war. His efforts were successful in part because of aid from Güshi Khan, the Oirat leader of the Khoshut Khanate. With Güshi Khan as a largely uninvolved overlord, the 5th Dalai Lama and his intimates established a civil administration which is referred to by historians as the Lhasa state. This Tibetan regime or government is also referred to as the Ganden Phodrang.
Document 9: Sino-Tibetan relations during the Ming dynasty: The Ming initiated sporadic armed intervention in Tibet during the 14th century, but did not garrison permanent troops there. At times the Tibetans also used armed resistance against Ming forays. The Wanli Emperor (r. 1572–1620) made attempts to reestablish Sino-Tibetan relations after the Mongol-Tibetan alliance initiated in 1578, which affected the foreign policy of the subsequent Qing dynasty (1644–1912) of China in their support for the Dalai Lama of the Gelug school. By the late 16th century, the Mongols were successful armed protectors of the Gelug Dalai Lama, after increasing their presence in the Amdo region. This culminated in Güshi Khan's (1582–1655) conquest of Tibet from 1637–1642 and the establishment of the Ganden Phodrang regime by the 5th Dalai Lama with his help.
Document 10: Sino-Tibetan relations during the Ming dynasty: Kolmaš writes that, as the Mongol presence in Tibet increased, culminating in the conquest of Tibet by a Mongol leader in 1642, the Ming emperors "viewed with apparent unconcern these developments in Tibet." He adds that the Ming court's lack of concern for Tibet was one of the reasons why the Mongols pounced on the chance to reclaim their old vassal of Tibet and "fill once more the political vacuum in that country." On the mass Mongol conversion to Tibetan Buddhism under Altan Khan, Laird writes that "the Chinese watched these developments with interest, though few Chinese ever became devout Tibetan Buddhists."
Document 11: Sino-Tibetan relations during the Ming dynasty: Laird writes that Altan Khan abolished the native Mongol practices of shamanism and blood sacrifice, while the Mongol princes and subjects were coerced by Altan to convert to Gelug Buddhism—or face execution if they persisted in their shamanistic ways. Committed to their religious leader, Mongol princes began requesting the Dalai Lama to bestow titles on them, which demonstrated "the unique fusion of religious and political power" wielded by the Dalai Lama, as Laird writes. Kolmaš states that the spiritual and secular Mongol-Tibetan alliance of the 13th century was renewed by this alliance constructed by Altan Khan and Sönam Gyatso. Van Praag writes that this restored the original Mongol patronage of a Tibetan lama and "to this day, Mongolians are among the most devout followers of the Gelugpa and the Dalai Lama." Angela F. Howard writes that this unique relationship not only provided the Dalai Lama and Panchen Lama with religious and political authority in Tibet, but that Altan Khan gained "enormous power among the entire Mongol population."
Document 12: Sino-Tibetan relations during the Ming dynasty: Meanwhile, the Tumed Mongols began moving into the Kokonor region (modern Qinghai), raiding the Ming Chinese frontier and even as far as the suburbs of Beijing under Altan Khan (1507–1582). Klieger writes that Altan Khan's presence in the west effectively reduced Ming influence and contact with Tibet. After Altan Khan made peace with the Ming dynasty in 1571, he invited the third hierarch of the Gelug—Sönam Gyatso (1543–1588)—to meet him in Amdo (modern Qinghai) in 1578, where he accidentally bestowed him and his two predecessors with the title of Dalai Lama—"Ocean Teacher". The full title was "Dalai Lama Vajradhara", "Vajradhara" meaning "Holder of the Thunderbolt" in Sanskrit. Victoria Huckenpahler notes that Vajradhara is considered by Buddhists to be the primordial Buddha of limitless and all-pervasive beneficial qualities, a being that "represents the ultimate aspect of enlightenment." Goldstein writes that Sönam Gyatso also enhanced Altan Khan's standing by granting him the title "king of religion, majestic purity". Rawski writes that the Dalai Lama officially recognized Altan Khan as the "Protector of the Faith".
Document 13: Sino-Tibetan relations during the Ming dynasty: Chen states that the fourth Dalai Lama Yonten Gyatso was granted the title "Master of Vajradhara" and an official seal by the Wanli Emperor in 1616. This was noted in the Biography of the Fourth Dalai Lama, which stated that one Soinam Lozui delivered the seal of the Emperor to the Dalai Lama. The Wanli Emperor had invited Yonten Gyatso to Beijing in 1616, but just like his predecessor he died before being able to make the journey.
Document 14: Sino-Tibetan relations during the Ming dynasty: The Mongol prince Godan, a grandson of Genghis Khan, raided as far as Lhasa. During his attack in 1240, Prince Godan summoned Sakya Pandita (1182–1251), leader of the Sakya school of Tibetan Buddhism, to his court in what is now Gansu in Western China. With Sakya Pandita's submission to Godan in 1247, Tibet was officially incorporated into the Mongol Empire during the regency of Töregene Khatun (1241–1246). Michael C. van Walt van Praag writes that Godan granted Sakya Pandita temporal authority over a still politically fragmented Tibet, stating that "this investiture had little real impact" but it was significant in that it established the unique "Priest-Patron" relationship between the Mongols and the Sakya lamas.
Document 15: Tibet: Tibet retained nominal power over religious and regional political affairs, while the Mongols managed a structural and administrative rule over the region, reinforced by the rare military intervention. This existed as a "diarchic structure" under the Yuan emperor, with power primarily in favor of the Mongols. Mongolian prince Khuden gained temporal power in Tibet in the 1240s and sponsored Sakya Pandita, whose seat became the capital of Tibet. Drogön Chögyal Phagpa, Sakya Pandita's nephew became Imperial Preceptor of Kublai Khan, founder of the Yuan dynasty.
ground_truth: In 1642
sub_queries: Who managed religious and regional political affairs? Answer: Tibet
When did the 5th Dalai Lama gain political control over Tibet ? Answer: In 1642