After the break-up of the Tibetan Empire in the mid-9th century, central rule was largely nonexistent over the region for 400 years. But Buddhism survived and when the Mongols conquered the region, Buddhism was adopted as the official religion of their empire. In 1271, Kublai Khan established the Yuan Dynasty and Tibet remained a semi-autonomous entity within it. From the second half of the 14th century until the early 17th, Tibet was ruled by competing Buddhist schools. However, it was during this period that the Gelug order was founded in 1409 and the institution of the Dalai Lama was established in 1569 with the priest-patron relationship between the Altan Khan and the 3rd Dalai Lama . The Dalai Lamas are said to be the reincarnates of the Bodhisattva of Compassion, Avalokiteśvara. It was when the 5th Dalai Lama Ngawang Lobsang Gyatso succeeded in establishing the Ganden Phodrang government and Gelug supremacy in Tibet, with the help of the Güshi Khan of the Khoshut Khanate, that the post took on the dual role of political and religious leadership . After Lobsang Gyatso's mortal passing in 1682, which was kept a secret for 15 years, there was a period of anarchy and invasions that eventually led to the establishment of Qing protectorate over Tibet in 1720 that would reach its peak in the 1790s in response to attacks by Nepal, be renewed in 1903 when the British invaded, and would last until 1912. Tibet became independent with the demise of the Manchu Qing dynasty and would remain so until 1950.

Which happened first, the Gelug order was founded or the institution of the Dalai Lama was established?
Gelug order was