Buddhism had been introduced into Tibet some years before, but the king who established it as the state religion was Trisong Deutsen, who lived in the later 700s or the early 800s. The daughter of one of his nobles was Tsogyal, who spent several years of her childhood resisting marriage to unwanted suitors and who was finally given protection in the court of the king.
In order to strengthen Buddhism in his country (under attack by followers of the older native religion), the king wished to build an imposing complex of temples at Samye, a site near his capital at Lhasa. He invited to his court an Indian teacher of Vajrayana Buddhism, Padmasambhava (literally, the lotus-born). Shortly after the teacher's arrival, the king gave him Tsogyal, to be his attendant and his consort in the Vajrayana rituals. She was in her early or mid-teens and already a follower of Buddhism; there is nothing in the literature that suggests she resisted being such a gift.
Padmasambhava gradually taught Tsoygal all of his spiritual doctrine and rituals. She helped make the temple complex a reality by winning over the kingdom's leading women and by debating with women who spoke for the older religion. When she had achieved spiritual maturity, she began to travel on her own, gathering followers for Vajrayana Buddhism.
After the death of Trisong Deutsen and the installation of a new king, Padmasambhava left Tibet; Tsogyal remained in her own country and continued to teach and to gather disciples around her. These came to consider her a "dakini" (literally, a sky-dancer), a deity who represented the feminine principle of wisdom; from this came the title "Yeshe" (literally, Primordial Wisdom).
While Padmasambhava was still in Tibet, Tsogyal had written down many of his teachings. Because he felt that in some cases the Tibetan people were not ready to hear them and in other cases that they would be more valuable in later, harder times, he and Tsogyal hid them in temples and other sacred spots, to be found by those who were worthy. The same was done with at least one biography of Padmasambhava written by Tsogyal after he had left Tibet, Padma bka than, and with a collection of Tsogyal's words and experiences recorded by her disciples, Bod kyi jo mo Ye-she Mtsho-rygal.... These hidden documents were called terma; most were discovered between the 1100s and the 1600s.