As a result of treaties imposed on China by foreign powers after the First (18391842) and Second Opium Wars (18561860), China was opened to foreign trade at a number of locations known as "treaty ports" where foreigners were permitted to live and conduct business. Also, created by the treaties was the doctrine of extraterritoriality, a system whereby citizens of foreign countries living in China were subject to the laws of their home country. Most favoured nation treatment under the treaties assured other countries of the fact that the same privileges would be afforded to them as well, and soon many nations, including the United States, operated merchant ships and navy gunboats on the waterways of China.