Thousands of years ago, the area where Taipei now stands was a lake. Over centuries, the lake dried up, becoming a dry basin punctuated with swamps and grassy lowlands. The people of the Pingpu tribe - probably descended from Pacific Islanders - lived in elevated areas surrounding the basin and fished the waterways in canoes. A few hundred years ago, a group of Han Chinese settled in the area. They also used the waterways to fish, keeping to the banks of the Tamsui River some distance from modern Taipei.
In 1790, a farmer from Fukien Province on the mainland established a farm at Takala in what is now central Taipei. This was the beginning of a large-scale migration to the area, and led to the formation of several settlements. The most concentrated area of settlement - the earliest in the Taipei area - was known as Manka. Other locations including Talungtung, Sungshan and Shihlin also became populated by Chinese mainland communities. Control of the emerging city of Taipei was divided among immigrants from different areas of mainland China. This broad power-sharing led to frequent armed clashes. After a large battle in 1853, settlers from Chuanchou fled north to Tataocheng on the banks of the Tamsui River. Their farming efforts eventually led to a new and prosperous community which dominated Manka by the late 19th century. The Tamsui River brought commerce and prosperity, with trade in tea and camphor taking place along the waterfront. Both Manka and Tataocheng sprang up because of their proximity to the Tamsui River, not only the vital force behind the development of early Taipei, but also a major artery in the city's subsequent development.
In 1875, the Prefecture of Taipei was established in what is now the Chungcheng District of the city. Taipei's early construction was based on traditional Chinese geomancy, with walls to the east and west, mountains surrounding and the Hsintien River as the required body of water in front. The city faced north-south with the four main walls penetrated by five city gates. The area within the walls was referred to as Cheng-nei ('inside the city walls'). The Ching Dynasty established administrative and financial agencies in the fledgling city and when the Japanese colonised Taiwan in 1895, they also set up administrative headquarters in Taipei and continued to develop the city. Under the management of its different rulers the area within the city walls evolved from wide open countryside into the administrative, economic and cultural centre of Taiwan in just 100 years.