The Meiji Restoration
In 1853, four American warships under Commodore Matthew Perry sailed into Edo Bay and demanded that Japan — closed to most foreign contact for 220 years under the sakoku policy — open its ports. The Tokugawa government, which had kept the country at peace through deliberate isolation, had no answer; Perry's black ships outgunned every fort in the bay. Within fifteen years the shogunate had collapsed. A coalition of young samurai from outlying domains — chiefly Satsuma and Chōshū — seized power in the name of the long-marginalized emperor, moved the capital to Tokyo, and announced, in 1868, that Japan would modernize on Western terms before the West could colonize it. They had perhaps thirty years, and the example of China's dismemberment before them.
What followed is, by some distance, the most successful crash modernization program in history. The samurai class voluntarily abolished itself; the 1873 conscription law and the loss of the stipend and the right to bear swords ended the warrior caste within a decade — Satsuma diehards rose in the 1877 Satsuma Rebellion and were crushed by the new peasant conscript army, sealing the point. A national army on Prussian lines and a navy on British lines replaced it. The legal code was rewritten on French and German models; the Meiji Constitution of 1889 borrowed Bismarck's Germany almost wholesale, vesting real power in an oligarchy of genrō behind a sovereign emperor. The unifying slogan was fukoku kyōhei — 'rich country, strong army'. A national rail network, a banking system, the Iwakura Mission's two-year fact-finding tour of the West, compulsory primary education, state-built model factories later sold to the zaibatsu conglomerates — all installed in a generation, mostly by importing foreign experts and then sending Japanese students abroad to replace them. By 1895, Japan defeated China in war and took Taiwan. By 1905, it defeated Russia at Tsushima and Mukden — the first time in the modern era that an Asian power had militarily beaten a European one, and a result that electrified anti-colonial movements from Cairo to Calcutta. By 1910, it had annexed Korea. The price of catching up was becoming an empire of the same kind that had originally threatened it, and the trajectory continued, with appalling consequences, into the 1940s.