The Kowloon Walled City was a densely populated and largely ungoverned enclave of China within the boundaries of Kowloon City, British Hong Kong. Built as an Imperial Chinese military fort, the walled city became a de jure enclave after the New Territories were leased to the United Kingdom in 1898. Its population increased dramatically after the end of the Japanese occupation of Hong Kong during World War II, attracting mostly refugees fleeing the renewed Chinese Civil War. By the late 1980s, the walled city contained roughly 35,000 residents within its territory of . From the 1950s to the 1970s, it was controlled by local triads and had high rates of prostitution, gambling, and drug abuse. In January 1987, the Hong Kong government announced plans to demolish the walled city. After an arduous eviction process, and the transfer of de jure sovereignty of the enclave from China to Britain, demolition began in March 1993 and was completed in April 1994. Kowloon Walled City Park opened in December 1995 and occupies the area of the former walled city. Some historical artefacts from the walled city, including its yamen building and remnants of its southern gate, have been preserved there. The history of the walled city can be traced back to the Song dynasty (960–1279), when a military outpost was set up to manage the salt trade in the area. Little took place for hundreds of years afterward, although 30 guards were stationed there in 1668. A small coastal fort was established around 1810 after Chinese forces abandoned Tung Lung Fort. In 1842, during Qing Daoguang Emperor's reign, Hong Kong Island was ceded to Britain by the Treaty of Nanking. As a result, the Qing authorities felt it necessary to improve the fort to rule the area and check further British influence. The improvements, including the formidable defensive wall, were completed in 1847. The walled city was captured by rebels during the Taiping Rebellion in 1854, before being retaken a few weeks later. The present walled city's "Dapeng Association House" forms the remnants of what was previously Lai Enjue's garrison.