Tak was a historical kingdom built over 2,000 years ago, even before the Sukhothai period. The ancient kingdom had its peak around the 1st century. By the 5th century the capital of this kingdom was moved south to Lavo (present day Lopburi Province). A city named Ban Tak was established by Jamadevi, princess of the Lavo kingdom, around 663 AD. It became part of the Sukhothai kingdom through battles led by Ramkhamhaeng the Great and formed the main fortress on the western front. The city was moved further west and renamed Mueang Rahang when the Ayuthaya kingdom was lost to Burma during King Maha Thammaracha's reign. The city was moved back to the east side of the Ping River during the early Bangkok period.