In 1925, Sun Yat-sen's Kuomintang started establishing a rival government in the southern city of Guangzhou together with the fledgling Communist Party of China. The economy of the north, overtaxed to support warlord adventurism, collapsed in 1927–28. General Chiang Kai-shek, who became KMT leader after Sun's death, started his military Northern Expedition campaign in order to overthrow the central government in Beijing. The government was overthrown in 1928 and Chiang established a new nationalist government in Nanjing. He later cut his ties with the communists and expelled them from the Kuomintang.
There was industrialization and modernization, but also conflict between the Nationalist government in Nanjing, the communists, remnant warlords, and the Empire of Japan. Nation-building took a backseat to war with Japan when the Imperial Japanese Army launched an offensive against China in 1937 that turned into a full-scale invasion. After the unconditional surrender of Japan in 1945, fighting quickly resumed between the KMT and the Communists, with both sides receiving foreign assistance due to the ongoing friction between the United States and Soviet Union. In 1947, the Constitution of the Republic of China replaced the Organic Law of 1928 as the country's fundamental law. In 1949, the Communists established the People's Republic of China, overthrowing the Nationalist government on the mainland, who retreated to Taiwan.
A republic was formally established on 1 January 1912 following the Xinhai Revolution, which itself began with the Wuchang Uprising on 10 October 1911, successfully overthrowing the Qing Dynasty and ending over two thousand years of imperial rule in China. From its founding until 1949 it was based on mainland China. Central authority waxed and waned in response to warlordism (1915–28), Japanese invasion (1937–45), and a full-scale civil war (1927–49), with central authority strongest during the Nanjing Decade (1927–37), when most of China came under the control of the Kuomintang (KMT) under an authoritarian one-party military dictatorship.
At the end of World War II in 1945, the Empire of Japan surrendered control of Taiwan and its island groups to the Allied Forces, and Taiwan was placed under the Republic of China's administrative control. The communist takeover of mainland China in the Chinese Civil War in 1949 left the ruling Kuomintang (KMT) with control over only Taiwan, Penghu, Kinmen, Matsu, and other minor islands. With the 1949 loss of mainland China in the civil war, the ROC government retreated to Taiwan and the KMT declared Taipei the provisional capital. The Communist Party of China took over all of mainland China and founded the People's Republic of China (PRC) in Beijing.
In 1912, after over two thousand years of imperial rule, a republic was established to replace the monarchy. The Qing Dynasty that preceded the republic experienced a century of instability throughout the 19th century, suffered from both internal rebellion and foreign imperialism. The ongoing instability eventually led to the outburst of Boxer Rebellion in 1900, whose attacks on foreigners led to the invasion by the Eight Nation Alliance. China signed the Boxer Protocol and paid a large indemnity to the foreign powers: 450 million taels of fine silver (around $333 million or £67 million at the then current exchange rates). A program of institutional reform proved too little and too late. Only the lack of an alternative regime prolonged its existence until 1912.