One of Thailand's oldest cities, Lopburi has been inhabited since the 4th century. After the 6th century its influence grew under the Dvaravati rulers, who dominated northern Thailand until the Khmers swept in from the east. From the beginning of the 10th century until the middle of the 13th, when the new Thai kingdom drove them out, the Khmers used Lopburi as their provincial capital. During the Sukhothai and early Ayutthaya
periods, the city's importance declined until, in 1664, King Narai made it his second capital to escape the heat and humidity of Ayutthaya. He employed French architects to build his palace; consequently, Lopburi is a strange mixture of Khmer, Thai, and western architecture.