Sukhothai, which was to be the capital of a united Siam in later centuries, had until the 13th century been controlled by the Khmer civilization based in Cambodia. However, much of the population was Thai (the result of an earlier colonisation) and they eventually overthrew their Khmer masters. In 1287 A.D. King Mengrai of Lan-Na, King Ramakhamphaeng of Sukhothai, and King Ngam-Muong of Phayao made an allegiance which led to the expulsion of all other claimants to control Northern Thailand, and laid the groundwork for the first Thai kingdom of Siam.