The Qing Dynasty, which lasted from 1644 until 1912, was the last imperial dynasty of China. In the 19th century, the Qing Dynasty experienced Western imperialism following two Opium Wars with Britain. China was forced to sign unequal treaties, pay compensation, allow extraterritoriality for foreign nationals, and cede Hong Kong to the British.

The weakening of the Qing regime led to increasing domestic disorder. In late 1850, southern China erupted in the Taiping Rebellion, a violent civil war which lasted until 1864. The rebellion was led by Hong Xiuquan, who was partly influenced by an idiosyncratic interpretation of Christianity. Although the Qing regime was eventually victorious, the civil war was one of the bloodiest in human history, costing at least 20 million lives, with some estimates of up to 40 million. Other costly rebellions followed the Taiping Rebellion, such as the Punti–Hakka Clan Wars (1855–67), Nien Rebellion (1851–1868), Miao Rebellion (1854–73), Panthay Rebellion (1856–1873) and the Dungan revolt (1862–1877).