Trading goods from China were extremely lucrative for Europeans, but suffered from one major problem: China was so large and reasonably well-developed that it was difficult to find products that the Chinese wished to import. Silver was one, to the extent that the drain on European specie metals was noticeably affecting the economy. Casting about for other possibilities, opium was discovered. Between 1821 and 1837 imports of the drug increased five-fold.
The Chinese government attempted to end this trade, on public health grounds -- numerous opium addicts were appearing in trading ports throughout China. The effort was largely successful, with the official in charge of the effort Lin Zexu[?], eventually forcing the British Chief Superintendent of Trade in China, Charles Elliott to hand over all remaining stocks of opium for destruction in May 1839.
However, the next month two British sailors murdered a Chinese man, and were tried under the principle of extraterritoriality: the sailors were brought to justice in a British court in Canton (modern-day Guangzhou). The Chinese, however, demanded that the principle be abrogated and the two men handed over to Chinese custody.
Refusing, the British were expelled from China. Preparing for war, they seized Hong Kong (then a minor outpost) as a base. Fighting began in July, when the HMS Volage[?] and HMS Hyacinth[?] defeated 29 Chinese ships. The next year, the British captured the Bogue forts[?] which guarded the mouth of the Pearl River[?] -- the waterway between Hong Kong and Canton. By January 1841, their forces commanded the high ground around Canton, then defeated the Chinese at the nearby city of Ningpo (modern-day Ningbo) and the military post of Chinhai[?].
By the middle of 1842, the British had defeated the Chinese at the mouth of their other great trading river, the Yangtze, and had occupied Shanghai. The war finally ended in August 1842, with the Treaty of Nanking.
The treaty committed the Chinese to free trade, including that of opium. Hong Kong was ceded to the UK, and the Treaty Ports[?] of Canton, Amoy (modern-day Xiamen), Foochow (modern-day Fuzhou), Shanghai, and Ningpo were opened to all traders. Reparations were also paid by the Chinese.
The ease with which the British forces had defeated the Chinese armies seriously affected the Qing dynasty's prestige. This almost certainly contributed to the Taiping Rebellion (1850-1862). For the victors, the Opium War paved the way for the opening up of the lucrative Chinese market and Chinese society for missionary purposes.