Over the past millennium, Shanghai transformed from a relatively insignificant market town and county capital into a major global metropolis. A combination of technical advances in agriculture, waterway management, and the natural changes in the course of some rivers and the silting of others led, in 1292, to the founding of the county capital Shanghai. The town went through alternate periods of growth and stagnation, but by the mid-19th century, it was an international trading hub with a population of a quarter of a million people. One of the turning points in its history came in 1842, the year that the Treaty of Nanking was signed by the Qing Empire and the United Kingdom and the Treaty Port of Shanghai opened up. Over the following century, Shanghai was divided into three main sections, each operating under its own laws and regulations: the International Settlement, the French Concession, and the Chinese city. In the 1930s, the fate of the city fell into the hands of yet another foreign power: Japan. After Japan’s surrender on 15 August 1945, Chinese nationalists and communists continued their struggle for control of the city for another four years until the People’s Liberation Army “liberated” Shanghai on 25 May 1949.