The First Opium War, during 1839â1842, was concluded by the Treaty of Nanjing in 1842. The treaty ceded the Hong Kong island to the United Kingdom in perpetuity, and it established five treaty ports at Shanghai, Canton, Ningpo, Fuchow, and Amoy.