During the First Opium War, the British navy defeated Eight Banners forces at Ningbo and Dinghai. Under the terms of the Treaty of Nanking, signed in 1843, Ningbo became one of the five Chinese treaty ports opened to virtually unrestricted foreign trade. Much of Zhejiang came under the control of the Taiping Heavenly Kingdom during the Taiping Rebellion, which resulted in a considerable loss of life in the province. In 1876, Wenzhou became Zhejiang's second treaty port.