Two wars (1839-1843, 1856-1860) fought between Britain and China in which Western powers gained significant commercial privileges and territory. The Opium Wars began when the Chinese government tried to stop the illegal importation of opium by British merchants.

The First Opium War started in 1839 when the Chinese government confiscated opium warehouses in Guangzhou (Canton). Britain responded by sending an expedition of warships to the city in February 1840. The British won a quick victory and the conflict was ended by the Treaty of Nanking (Nanjing) on August 29, 1842. By this treaty, and a supplementary one signed on October 8, 1843, China was forced to pay a large indemnity, open five ports to British trade and residence, and cede Hong Kong to Britain. The treaty also gave British citizens in China the right to be tried in British courts. Other Western powers demanded, and were granted, similar privileges.

In October 1856, Guangzhou police boarded the British ship Arrow and charged its crew with smuggling. Eager to gain more trading rights, the British used the incident to launch another offensive, precipitating the Second Opium War, also known as the Arrow War. British forces, aided by the French, won another quick military victory in 1857. When the Chinese government refused to ratify the Treaty of Tianjin, which had been signed in 1858, the hostilities resumed. In 1860, after British, American and French troops had occupied Beijing and burned the Summer Palace, the Chinese agreed to ratify the treaty. The treaty opened additional trading ports, allowed foreign emissaries to reside in Beijing, admitted Christian missionaries into China, and opened travel to the Chinese interior. Later negotiations legalized the importation of opium.