Buddhism entered Tibet twice: in the seventh century Tubo's Songtsen Gampo took princesses from Nepal and Tang China and built temples for the faith; in the eighth century Trisong Detsen invited Śāntarakṣita and Padmasambhava, built Samye monastery and ordained monks, the "earlier diffusion"; after Langdarma's persecution (842) the "later diffusion" revived the faith with Atiśa's arrival. The Nyingma, Sakya, Kagyu and Kadam schools arose together; Kublai Khan honoured Phags-pa as imperial preceptor and the Sakya school held religious and political power. In 1409 Tsongkhapa founded the Gelug (Yellow) school, reforming discipline and the stages of study, and the Dalai and Panchen reincarnation lines took shape; in 1578 Altan Khan received Sonam Gyatso and the Yellow teaching entered the Mongol steppe, the golden lineage and the Gelug school supporting each other. The Qing court honoured the Gelug school and installed resident hutuktus in Beijing, and in 1793 established the golden urn lottery for recognizing reincarnations. Tulku reincarnation and the union of church and state are Tibetan Buddhism's unique institutional creations; sutra, vinaya and abhidharma coexisted with logic and medicine, and its influence reaches Mongolia, Tibet, the Manchus and the Himalayan lands to this day.