In the final decades of the 9th century AD, it served as the official state temple of King Indravarman I in the ancient city of Hariharalaya, located in an area that today is called Roluos.
Contact is inferred to have occurred between the Khmer kingdom and the Sailendra dynasty in Java, who would have transmitted to Cambodia not only ideas, but also technical and architectural details of Borobudur, including arched gateways in corbelling method.
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 Yaśodharapura around a new temple mountain called Bakheng.
The inner moat delimits a 400 by 300 metres area, with remains of a laterite wall and four cruciform gopuram, and it is crossed by a wide earthen causeway, flanked by seven-headed nāgas, such as a draft of nāga bridge .
On the top there is a single tower that is much later in provenance, and the architectural style of which is not that of the 9th century foundations of Hariharalaya, but that of the 12th-century temple city Angkor Wat.