Phimai is a township in the Nakhon Ratchasima Province in the northeast of Thailand. As of 2005 the town has a population of 9,768. The town is the administrative center of the Phimai district. In the aftermath of the fall of the Ayutthaya Kingdom in 1767, attempts were made to set up five separate states, with Prince Teppipit, a son of king Boromakot, attempting to establish Phimai as one, holding sway over eastern provinces including Nakhon Ratchasima.
The weakest of the five, Prince Teppipit was the first defeated and was executed in 1768. Phimai had also been an important town at the time of the Khmer. The temple Prasat Hin Phimai, located in the center of the town, was one of the major Khmer temples in ancient Thailand, connected with Angkor by an ancient Khmer Highway, and oriented so as to face Angkor as its cardinal direction. The site is now protected as the Phimai Historical Park.