The First and Second Opium Wars between the Qing dynasty and several Western powers led to the forced signing of several unequal treaties by the Chinese government, which granted subjects of the foreign nations in question extraterritoriality in China, which included being exempted from the Great Qing Legal Code. According to historian Ronald C. Po, foreign exemption from Chinese laws as a result of the unequal treaties "substantially challenged" Chinese control over its maritime border.
