Angkor
In the early days of Angkor, the worship of Vishnu was secondary to that of Shiva. The relationship seems to have changed with the construction of Angkor Wat by King Suryavarman II as his personal mausoleum at the beginning of the 12th century. The central religious image of Angkor Wat was an image of Vishnu, and an inscription identifies Suryavarman as "Paramavishnuloka," or "he who enters the heavenly world of Vishnu." Religious syncretism, however, remained thoroughgoing in Khmer society: the state religion of Shaivism was not necessarily abrogated by Suryavarman's turn to Vishnu, and the temple may well have housed a royal lingam. Furthermore, the turn to Vaishnavism did not abrogate the royal personality cult of Angkor. by which the reigning king was identified with the deity. According to Angkor scholar Georges Coedès, "Angkor Wat is, if you like, a vaishnavite sanctuary, but the Vishnu venerated there was not the ancient Hindu deity nor even one of the deity's traditional incarnations, but the king Suryavarman II posthumously identified with Vishnu, consubstantial with him, residing in a mausoleum decorated with the graceful figures of apsaras just like Vishnu in his celestial palace." Suryavarman proclaimed his identity with Vishnu, just as his predecessors had claimed consubstantiation with Shiva.
Angkor
Following the death of Suryavarman around 1150 AD, the kingdom fell into a period of internal strife. Its neighbors to the east, the Cham of what is now southern Vietnam, took advantage of the situation in 1177 to launch a water-borne invasion up the Mekong River and across Tonlé Sap. The Cham forces were successful in sacking the Khmer capital of Yaśodharapura and in killing the reigning king. However, a Khmer prince who was to become King Jayavarman VII rallied his people and defeated the Cham in battles on the lake and on the land. In 1181, Jayavarman assumed the throne. He was to be the greatest of the Angkorian kings. Over the ruins of Yaśodharapura, Jayavarman constructed the walled city of Angkor Thom, as well as its geographic and spiritual center, the temple known as the Bayon. Bas-reliefs at the Bayon depict not only the king's battles with the Cham, but also scenes from the life of Khmer villagers and courtiers. Jayavarman oversaw the period of Angkor's most prolific construction, which included building of the well-known temples of Ta Prohm and Preah Khan, dedicating them to his parents. This massive program of construction coincided with a transition in the state religion from Hinduism to Mahayana Buddhism, since Jayavarman himself had adopted the latter as his personal faith. During Jayavarman's reign, Hindu temples were altered to display images of the Buddha, and Angkor Wat briefly became a Buddhist shrine. Following his death, the revival of Hinduism as the state religion included a large-scale campaign of desecrating Buddhist images, and continued until Theravada Buddhism became established as the land's dominant religion from the 14th century.