The Opium Wars or the Anglo-Chinese Wars were two wars fought in the mid-1800s that were the climax of a long dispute between China and Britain. These wars led to fall of Qing Dynasty, Treaty of Nanjing' in favor of Britain; as China agreed to open several low-tariff trade ports to Britain, yielded Hong Kong to Britain, and allowed British missionaries to work in China.

In the second war, France fought alongside Britain. The conflict began with the growing trade deficit Britain had with China and the smuggling of opium to China by the British.
Direct maritime trade between Europe and China started in the 16th century, after Portuguese settlement of Goa in India, shortly followed by Macau in southern China. After Spanish acquisition of the Philippines, the pace of exchange between China and the West accelerated dramatically. Manila galleons brought in far more silver to China than the ancient land route in interior Asia. The Qing government attempted to limit contact with the outside world to a minimum for reasons of internal control. Qing only allowed trade through the port of Canton (now Guangzhou). Severe red-tape and licensed monopolies were set up to restrict the trade flow. The result was very high retail price for imported goods after myriads of tax collectors and middlemen had their take. That led to limited demand for imported goods. In order to prevent a huge balance of trade deficit, Spain began to sell opium to the Chinese, along with new products such as tobacco and corn.

As a result of high demand for tea in Britain and the low demand for British commodities in China, Britain had to trade tea for silver. Britain was on the gold standard, so it had to buy silver from the European continent. Turmoil on the continent after the French Revolution and subsequent Napoleonic Continental System put a restriction on that trade. To find alternative goods for exchange with China, Britain began exporting opium to China from British India. The opium trade took off rapidly, and the silver flow began to reverse. China had few silver mines of its own; the drop in silver inflow caused a consternation at the court. The Qing Emperor (Dao Guan) had banned opium in China, citing its harmful effects on health and deleterious impact on societal productivity. 

In 1773, the Governor-General of Bengal pursued the monopoly on the sale of opium in earnest, and abolished the old opium syndicate at Patna. For the next 50 years, opium would be key to the East India Company's hold on India. Since importation of opium into China was against Chinese law, the British East India Company would buy tea in Canton on credit, carrying no opium, but would instead sell opium at the auctions in Calcutta leaving it to be smuggled to China. In 1797, the company ended the role of local Bengal purchasing agents and instituted the direct sale of opium to the company by farmers.

British exports of opium to China skyrocketed from an estimated 15 tons in 1730, to 75 tons in 1773, shipped in over two thousand "chests", each containing 140 pounds of opium.

In 1799, the Chinese Empire reaffirmed its ban on opium imports, and in 1810 a decree was issued stating; "Opium has a harm. Opium is a poison, undermining our good customs and morality. Its use is prohibited by law. Now the commoner, Yang, dares to bring it into the Forbidden City. Indeed, he flouts the law!"

The decree had little effect; The Qing government was located in Beijing, in the north, too far away to control the merchants who smuggled opium into China from the south. The lack of governmental action, the addictive properties of the drug, the desire for more profit by the British East India Company and merchants, and the fact that Britain wanted silver combined to further the opium trade. In the 1820s, opium trade averaged 900 tons per year from Bengal to China.

In 1834, to accommodate the revocation of the East India Company's monopoly, the British sent Lord Napier to
Macao. He attempted to circumvent the restrictive Canton Trade laws, which forbade direct contact with Chinese officials, and was turned away by the governor of Macao, who promptly closed trade starting on September 2 of that year. The British were not yet ready to force the matter, and agreed to resume trade under the old restrictions, even though Lord Napier implored them to force open the port.

Within the Chinese mandarinate, there was a debate on legalizing opium trade itself, but this was rejected in favor of continued restrictions. In 1838, the death penalty was imposed for native drug traffickers; by this time the British were selling 1,400 tons annually to China. In March of 1839, a new strict Confucianist commissioner, Lin Zexu was appointed by the emperor to control the opium trade at the port of Canton. He immediately enforced the imperial demand that there be a permanent halt to drug shipments into China. When the British refused to end the trade, Lin imposed a trade embargo on the British. On March 27, 1839, Charles Elliot, British Superintendent of Trade, demanded that all British subjects turn over opium to him, to be confiscated by Commissioner Lin Zexu, amounting to nearly a year's supply of the drug. After the opium was surrendered, trade was restarted on the condition that no more drugs were smuggled into China. Lin demanded that British merchants had to sign a bond promising not to deal in opium under penalty of death. The British officially opposed signing of the bond but some British merchants that did not deal in opium were willing to sign. Lin then disposed of the opium, by dissolving it with water, salt and lime and flushing it out into the ocean.

To avoid direct conflict, Lin also attempted diplomacy. In 1839, Lin wrote a letter to Queen Victoria, questioning her royal government's moral reasonings for enforcing strict prohibition of opium trade within England, Ireland, and Scotland while reaping profits from such trade in the Far East.

Side stepping the moral questions, the British government and merchants accused Lin of destroying their private property, roughly three million pounds of opium. The British responded by sending warships and soldiers, along with a large British Indian army, which arrived in June of 1840.

British military superiority was evident during the armed conflict. British warships attacked coastal towns at will, and their troops, armed with modern muskets and cannons, were able to easily defeat the Qing forces. The British took Canton and then sailed up the Yangtze and took the tax barges, slashing the revenue of the imperial court in Beijing to just a small fraction.

In 1842, the Qing authorities sued for peace, which concluded with the Treaty of Nanjing negotiated in August of that year and accepted in 1843. In the treaty, China agreed to open several low-tariff trade ports to Britain, yielded Hong Kong to Britain, and allowed British missionaries to work in China. 

The Second Opium War, or Arrow War, broke out following an incident in which Chinese officials boarded a vessel near the
port of Whampoa, the Arrow in October 1856. Arrow was owned by a Chinese privateer. The Chinese owner registered the vessel with the British authorities in Hong Kong with the purpose of making privateering easier in mind. He received a one year permit from the Hong Kong authorities, but it had already expired when inspected by the Chinese officials who boarded the vessel. Therefore, it was a Chinese national matter and not related with the British in any way. The crew of the Arrow were accused of piracy and smuggling, and were arrested. In response, the British consulate in Guangzhou insisted that Arrow was a British vessel. The British accused the Chinese officials of tearing down and insulting the British flag during inspection. The Second Opium War was started when British forces attacked Guangzhou in 1856.

The Treaty of Tientsin was created in July 1858, but was not ratified by China until two years later; this would prove to be a very important document in China's early modern history, as it was one of the primary unequal treaties.

Hostilities broke out once more in 1859, after China refused the establishment of a British embassy in Beijing, which had been promised by the Treaty of Tientsin. Fighting erupted in Hong Kong, and in Beijing, where the British set fire to the SummerPalace and the OldSummerPalace after considerable looting took place.

In 1860, at the Convention of Peking, China ratified the Treaty of Tientsin, ending the war, and granting a number of privileges to British subjects within China.