Dzogchen, the great completeness, is a Mahayana system of practice leading to enlightenment and involves a view of reality, way of meditating, and way of behaving . It is found earliest in the Nyingma and Bon (pre-Buddhist) traditions.
Zhang-zhung was conquered by Yarlung (Central Tibet) in 645 CE. The Yarlung Emperor Songtsen-gampo had wives not only from the Chinese and Nepali royal families (both of whom brought a few Buddhist texts and statues), but also from the royal family of Zhang-zhung. The court adopted Zhang-zhung (Bon) burial rituals and animal sacrifice, although Bon says that animal sacrifice was native to Tibet, not a Bon custom. The Emperor built thirteen Buddhist temples around Tibet and Bhutan, but did not found any monasteries.
This pre-Nyingma phase of Buddhism in Central Tibet did not have dzogchen teachings. In fact, it is difficult to ascertain what level of Buddhist teachings and practice were introduced. It was undoubtedly very limited, as would have been the case with the Zhang-zhung rites.
The next major figure, Emperor Tri Songdetsen, was cautious of the Chinese and paranoid of Zhang-zhung, most likely because his pro-Chinese father had been assassinated by the xenophobic, conservative Zhang-zhung political faction in the imperial court. In 761, he invited the Indian Buddhist abbot Shantarakshita to Tibet. There was a smallpox epidemic. The Zhang-zhung faction in court blamed Shantarakshita and deported him from the land. On the abbot's advice, the Emperor then invited Guru Rinpoche (Padmasambhava) from Swat (northwestern Pakistan), who drove out the demons who had caused the smallpox. The Emperor then reinvited Shantarakshita.
Guru Rinpoche left in 774, without having completed the full transmission of dzogchen. Seeing that the times were not ripe, he buried some texts as buried treasure texts (gter-ma, "terma"). They were exclusively texts on dzogchen.
Samyay Monastery (the first monastery in Tibet with the first seven Tibetan monks) was completed shortly afterwards. Chinese from the Chan (Jap. Zen) tradition, Indian, and Zhang-zhung translators worked together there. Buddhism became the state religion in 779, probably because Emperor Tri Songdetsen needed an alternative culture to Zhang-zhung for unifying the country. The Emperor appointed three families to support each monk.
Tibet conquered Dunhuang, (a Buddhist oasis on the Silk Route northwest of Tibet) from China in 781. Yet, the Chinese emperor sent two Chinese monks to Samyay every other year from 781, to maintain his influence.
Shantarakshita died in 783, warning of trouble from the Chinese, and advised inviting his disciple Kamalashila to debate them, which the Tibetans did.
The next year, in 784, a grand persecution and exile of the Bonpos (followers of Bon) took place. Most went to Gilgit (northern Pakistan) or Yunnan (southwestern China). According to the traditional Bon account, Zhang-zhung Drenpa-namka buried the Bon texts (all categories, not just dzogchen) at this time for safekeeping.
Historical and political analysis reveals that the reason for the exile was suspicion that the xenophobic conservative Zhang-zhung political faction might assassinate the Emperor for being pro-Indian, as they had done to his father. Moreover, the state kept the Bon burial rituals and sacrifices. Therefore, it is reasonable to conclude that it was a persecution of the Zhang-zhung political faction, not a persecution of the Bon religion.
For this reason, several Western scholars assert that the term Bonpo (followers of Bon) in this period had primarily a political rather than religious reference. It was used for the Zhang-zhung political faction at the court and their followers, rather than for the spiritual leaders who performed the Zhang-zhung religious rites at the court and their followers.
Emperor Tri Songdetsen sent Vairochana, one of the seven original Tibetan monks from Samyay, to India for more texts. He brought back both dzogchen and Buddhist medicine tantras, and invited the Indian dzogchen master Vimalamitra, who brought more texts.
The Samyay debate was in 792-794, between Indian and Chinese Buddhism. The Indian side, led by Kamalashila, won; the Chinese, led by Hoshang Mahayana (Chinese for "Mahayana monk"), were expelled from Tibet. The Tibetans officially adopted Indian Buddhism and Indian Buddhist medicine, although they kept some Chinese medicine influences combined with it.
Shortly afterwards, the Tibetan Vairochana was exiled after Indian abbots slandered him for revealing too much, so he buried more dzogchen texts, as did the Indian Vimalamitra.
From the treasure texts buried by Vairochana and Vimalamitra and those buried earlier by Guru Rinpoche, the dzogchen teachings were later divided into three divisions.
1. semdey (sems-sde, mind division), emphasizing pure awareness (rig-pa) as the basis for all (kun-gzhi, Skt. alaya),
2. longdey (klong-sde, open sphere division), emphasizing the open sphere aspect (klong) of pure awareness as the basis for all,
3. menngag-dey (man-ngag sde, personal instructions division), also called nyingtig (snying-thig, heart essence division), emphasizing pure awareness being primally pure (ka-dag).
The first two derive from the treasure texts buried by the Tibetan monk Vairochana and are not practiced much today. The mind division comes from Indian texts that Vairochana translated; the open sphere division from his oral teachings. The personal instructions division has two sections from the two Indian teachers, one from Guru Rinpoche: Kadro Nyingtig, Dakini Heart Essence Teachings) and one from Vimalamitra: Vima Nyingtig, Vimalamitra's Heart Essence Teachings).