According to the Blue Annals, completed in 1476, the temple was constructed between 787 and 791 under the patronage of King Trisong Detsen.
Earlier in date is the Testament of Ba, the oldest account of the construction of the temple.
This records that the foundations were laid in the 'Hare Year'.
This corresponds to 763 or 775, with the completion and consecration of the main shrine taking place in the 'Sheep Year'.
This is thought to correspond to 779.
 
The plan was supposedly modeled on the design of Odantapuri in what is now Bihar, India.
The arrangement of the temple with a main shrine in the middle with fours shrines of different colours at the cardinal points, and the whole surrounded by a circular wall, represents the Buddhist universe as three dimensional mandala.
This idea is found in a number of temples of the period in South East Asia and East Asia such as the Tōdai-ji in Japan.
As at the Tōdai-ji, the Samye temple is dedicated to Vairocana.
A seminal text of Vairocana is the Mahavairocana Tantra, composed in India in the seventh century and translated into Chinese and Tibetan soon after.
The history of Samye is dealt with in this section; for the art and architectural features and their history, see below.
 
The Samye pillar or རྡོ་རིང་ and its inscription 
There are many traditions about Samye compiled after the tenth century.
One of the few documents belonging to the eighth century proper--but not carrying an actual date--is an inscription on the stone pillar (རྡོ་རིང་) preserved in front of the temple.
This records the building of temples at Lhasa and Brag Mar (i.e. Samye), and that the king, ministers and other nobles made solemn oaths to preserve and protect the endowments of the monastery.
The term used for these endowments is 'necessities' or 'meritorious gifts' (Tib.
ཡོ་བྱད་ Sanskrit deyadharma).

The Samye bell inscription 
A second dynastic record at Samye is on the large bronze bell in the entrance to the temple.
This gives an account of the making of the bell by one of the queens of King Trisong Detsen.
The text has been translated as follows: 
"Queen Rgyal mo brtsan, mother and son, made this bell in order to
worship the Three Jewels of the ten directions.
And [they] pray that, by the
power of that merit, Lha Btsan po Khri Srong lde brtsan, father and son,
husband and wife, may be endowed with the harmony of the sixty
melodious sounds, and attain supreme enlightenment."

Histories of Samye after the Dynastic Period 
According to post-dynastic accounts such as the Testament of Ba and other accounts, such as that compiled by Bsod-nams-rgyal-mtshan (1312-1374), the Indian monk Śāntarakṣita made the first attempt to construct the monastery while promoting his sutra-centric version of Buddhism.
Finding the Samye site auspicious, he set about to build a structure there.
However, the building would always collapse after reaching a certain stage.
Terrified, the construction workers believed that there was a demon or obstructive tulku in a nearby river making trouble.

When Shantarakshita's contemporary Padmasambhava arrived from northern India, he was able to subdue the energetic problems obstructing the building of Samye.
According to the 5th Dalai Lama, Padmasambhava performed the Vajrakilaya dance and enacted the rite of namkha to assist Trisong Detsen and Śāntarakṣita clear away obscurations and hindrances in the building of Samye: 
The great religious master Padmasambhava performed this dance in order to prepare the ground for the Samye Monastery and to pacify the malice of the lha [local mountain god spirits] and srin [malevolent spirits] in order to create the most perfect conditions."
He went on to say that after Padmasambhava consecrated the ground he erected a thread-cross — a web colored thread woven around two sticks — to catch evil.
Then the purifying energy of his dance forced the malevolent spirits into a skull mounted on top of a pyramid of dough.
His tantric dance cleared away all the obstacles, enabling the monastery to be built in 767.
 The dance was memorialized by the construction of V
According to the Blue Annals, completed in 1476, the temple was constructed between 787 and 791 under the patronage of King Trisong Detsen. Earlier in date is the Testament of Ba, the oldest account of the construction of the temple. This records that the foundations were laid in the 'Hare Year'. This corresponds to 763 or 775, with the completion and consecration of the main shrine taking place in the 'Sheep Year'. This is thought to correspond to 779.  
The plan was supposedly modeled on the design of Odantapuri in what is now Bihar, India. The arrangement of the temple with a main shrine in the middle with fours shrines of different colours at the cardinal points, and the whole surrounded by a circular wall, represents the Buddhist universe as three dimensional mandala. This idea is found in a number of temples of the period in South East Asia and East Asia such as the Tōdai-ji in Japan. As at the Tōdai-ji, the Samye temple is dedicated to Vairocana. A seminal text of Vairocana is the Mahavairocana Tantra, composed in India in the seventh century and translated into Chinese and Tibetan soon after. The history of Samye is dealt with in this section; for the art and architectural features and their history, see below.  
The Samye pillar or རྡོ་རིང་ and its inscription 
There are many traditions about Samye compiled after the tenth century. One of the few documents belonging to the eighth century proper--but not carrying an actual date--is an inscription on the stone pillar (རྡོ་རིང་) preserved in front of the temple. This records the building of temples at Lhasa and Brag Mar (i.e. Samye), and that the king, ministers and other nobles made solemn oaths to preserve and protect the endowments of the monastery. The term used for these endowments is 'necessities' or 'meritorious gifts' (Tib. ཡོ་བྱད་ Sanskrit deyadharma).
The Samye bell inscription 
A second dynastic record at Samye is on the large bronze bell in the entrance to the temple. This gives an account of the making of the bell by one of the queens of King Trisong Detsen. The text has been translated as follows: 
"Queen Rgyal mo brtsan, mother and son, made this bell in order to
worship the Three Jewels of the ten directions. And [they] pray that, by the
power of that merit, Lha Btsan po Khri Srong lde brtsan, father and son,
husband and wife, may be endowed with the harmony of the sixty
melodious sounds, and attain supreme enlightenment."
Histories of Samye after the Dynastic Period 
According to post-dynastic accounts such as the Testament of Ba and other accounts, such as that compiled by Bsod-nams-rgyal-mtshan (1312-1374), the Indian monk Śāntarakṣita made the first attempt to construct the monastery while promoting his sutra-centric version of Buddhism. Finding the Samye site auspicious, he set about to build a structure there. However, the building would always collapse after reaching a certain stage. Terrified, the construction workers believed that there was a demon or obstructive tulku in a nearby river making trouble.
When Shantarakshita's contemporary Padmasambhava arrived from northern India, he was able to subdue the energetic problems obstructing the building of Samye. According to the 5th Dalai Lama, Padmasambhava performed the Vajrakilaya dance and enacted the rite of namkha to assist Trisong Detsen and Śāntarakṣita clear away obscurations and hindrances in the building of Samye: 
The great religious master Padmasambhava performed this dance in order to prepare the ground for the Samye Monastery and to pacify the malice of the lha [local mountain god spirits] and srin [malevolent spirits] in order to create the most perfect conditions." He went on to say that after Padmasambhava consecrated the ground he erected a thread-cross — a web colored thread woven around two sticks — to catch evil. Then the purifying energy of his dance forced the malevolent spirits into a skull mounted on top of a pyramid of dough. His tantric dance cleared away all the obstacles, enabling the monastery to be built in 767.  The dance was memorialized by the construction of V
Samye