Germany before unification was not a country but a civilization of states. The Holy Roman Empire had dissolved into, after 1648, some three hundred effectively sovereign principalities, duchies, bishoprics, free cities and knights' estates, the Kleinstaaterei that made Germany a patchwork of tolls, laws, armies and courts. The Empire provided a loose constitutional frame, the emperor, the Imperial Diet at Regensburg, imperial courts, but real power lay with the princes, above all the Habsburg emperors in Vienna and the Hohenzollern kings of Prussia, whose dualism dominated German history from 1740.
Napoleon simplified the map by conquest. The mediatization of 1803 abolished most of the ecclesiastical states and folded the small territories into larger ones; the old Empire itself was dissolved in 1806, when a league of German princes formed the Confederation of the Rhine under French protection. The reforms of the era, Prussia's Stein and Hardenberg measures after the catastrophe of Jena (1806), Bavaria's and Baden's modernizations, created efficient centralized administrations, emancipated peasants and Jews to varying degrees, and, in the Wars of Liberation (1813-1815), awakened a German national consciousness that the restored princes refused to satisfy.
The Congress of Vienna replaced the Empire with the German Confederation (Deutscher Bund), thirty-nine states under Austrian presidency with a diet at Frankfurt, deliberately too weak to act except in suppressing nationalism, Metternich's Carlsbad Decrees (1819) made that explicit. Economic integration outran politics: Prussia's Zollverein (customs union, 1834) bound most German states into a free-trade area that pointedly excluded Austria, making Prussia the economic leader of Germany a generation before it became the political one. The liberal and national movement of the Vormarz era, Burschenschaften and the Frankfurt Parliament of 1848, demanded unity and constitutions and was defeated, leaving unity to be achieved by state power instead.
The path to unification ran through the rivalry of the two German great powers. Prussia under King William I and, from 1862, Bismarck built the army that would decide the German question, first taking Schleswig and Holstein from Denmark with Austria in 1864, then provoking the Austro-Prussian War of 1866: Koniggratz expelled Austria from German affairs, dissolved the Confederation, and let Prussia annex Hanover, Hesse-Kassel, Nassau and Frankfurt outright, founding the North German Confederation. The southern states were drawn in through the Franco-Prussian War (1870-1871), and on 18 January 1871 the German Empire was proclaimed in the Hall of Mirrors at Versailles. The centuries of particularism ended in a federal empire dominated by Prussia.