The British acquired Hong Kong in three phases between 1840 and 1899. The initial acquisitions was to establish a trading port for commercial activity in China, while the subsequent expansion was primarily to protect the harbour and subsequent dockyards from external enemy attack. The initial occupation of Hong Kong was a result of the First Opium War, 1839-41.
The Qing Government of China attempted to restrict the import of opium from British India into Canton. The technologically superior British forces used a series of amphibious operations in the Canton and Yangtze Rivers to dismantle Chinese resistance. In August 1841 the Chinese signed the Treaty of Nanking and ceded Hong Kong Island to Britain as a Colony. The Treaty also created five Treaty Ports where foreigners could live and trade in China. These were at Shanghai, Canton (Guangzhou), Ningpo (Ningbo), Foochow (Fuzhou) and Amoy (Xiamen).