The first wave of globalization (1830-1914) witnessed a decline in the number of countries from 125 to 54. Political consolidation was often achieved through war and conquest. The second wave of globalization (1950-present) has led instead to an increase in the number of countries to a record high of more than 190. Political fragmentation has been accompanied by the creation of peaceful structures of supranational governance. This paper develops a theoretical model of the interaction between globalization and political structure that accounts for these trends and their reversal. We show that political structure adapts to steadily expanding trade opportunities in a non-monotonic way. Borders hamper trade. In its early stages, the political response to globalization consists of removing borders by increasing country size. War is then an appealing way of conquering markets. In its later stages, however, the political response to globalization is to remove the cost of borders by creating international economic unions. As a result, country size declines and negotiation replaces war as a tool to ensure market access.