Thus began the first Opium War, in which Britain's industrialized military might was proven in China's rout. The Treaty of Nanking, which ended the war in 1842 largely on British terms, imposed numerous restrictions on Chinese sovereignty and opened five ports to European traders.