Britain occupied Hong Kong during the First Opium War. China lost the first Opium War and had to cede Hong Kong to the British as part of the peace terms. During the Second Opium War, Britain gained Kowloon. Eventually, a lease was worked out between Britain and China.