In the High Middle Ages, the regional dukes, princes and bishops gained power at the expense of the emperors. Martin Luther led the Protestant Reformation against the Catholic Church after 1517, as the northern states became Protestant, while the southern states remained Catholic. The two parts of the Holy Roman Empire clashed in the Thirty Years' War (1618–1648), which was ruinous to the twenty million civilians. 1648 marked the effective end of the Holy Roman Empire and the beginning of the modern nation-state system, with Germany divided into numerous independent states, such as Prussia, Bavaria and Saxony.
After the French Revolution and the Napoleonic Wars (1803–1815), feudalism fell away and liberalism and nationalism clashed with reaction. The 1848 March Revolution failed. The Industrial Revolution modernized the German economy, led to the rapid growth of cities and to the emergence of the Socialist movement in Germany. Prussia, with its capital Berlin, grew in power. German universities became world-class centers for science and the humanities, while music and the arts flourished. Unification was achieved with the formation of the German Empire in 1871 under the leadership of Prussian Chancellor Otto von Bismarck. The new Reichstag, an elected parliament, had only a limited role in the imperial government. Germany joined the other powers in colonial expansion in Africa and the Pacific.
Germany was the dominant power on the continent. By 1900, its rapidly expanding industrial economy passed Britain's, allowing a naval race and an aggressive foreign policy. Germany led the Central Powers in World War I (1914–1918) against France, Great Britain, Russia and (by 1917) the United States. Defeated and partly occupied, Germany was forced to pay war reparations by the Treaty of Versailles and was stripped of its colonies as well as Polish areas and Alsace-Lorraine. The German Revolution of 1918–19 deposed the emperor and the various kings and princes, leading to the establishment of the Weimar Republic, an unstable parliamentary democracy.