In 802 A.D., the first king of Angkor Jayavarman II declared the sovereignty of Cambodia. After ups and downs, he established his capital at Hariharalaya. Few decades later, his successors constructed Bakong in stages as the first temple mountain of sandstone at Angkor. The inscription on its stele (classified K.826) says that in 881 King Indravarman I dedicated the temple to the god Shiva and consecrated its central religious image, a lingam whose name Sri Indresvara was a combination of the king's own and the suffix "-esvara" which stood for Shiva ("Iśvara"). According to George Coedes, the devarāja cult consisted in the idea of divine kingship as a legitimacy of royal power, but later authors stated that it doesn't necessarily involve the cult of physical persona of the ruler himself
.
Bakong enjoyed its status as the state temple of Angkor for only a few years, but later additions from the 12th or 13th centuries testify that it was not abandoned. Toward the end of the 9th century, Indravarman's son and successor Yasovarman I moved the capital from Hariharalaya to the area north of Siem Reap now known as Angkor, where he founded the new city of Yasodharapura around a new temple mountain called Bakheng.
Bakong enjoyed its status as the state temple of Angkor for only a few years, but later additions from the 12th or 13th centuries testify that it was not abandoned. Toward the end of the 9th century, Indravarman's son and successor Yasovarman I moved the capital from Hariharalaya to the area north of Siem Reap now known as Angkor, where he founded the new city of Yasodharapura around a new temple mountain called Bakheng.