In this paper, we examine the role of trade shocks in promoting the diffusion of elementary education in subnational units in Brazil during a period (1889-1930) in which they had relative financial autonomy to collect export taxes and spend on public goods. The argument is that trade shocks affect asymetrically the tax revenues of state governments and, thus, their expenditures on elementary education per capita according to what crop mix they had. We then show that states with more egalitarian and democratic institutions use positive trade shocks to invest in education, while the opposite takes place in states with less democratic institutions (e.g., in states that had more slaves). We also show using OLS and instrumental variables that positive trade shocks increased expenditures on education per capita and led to higher literacy rates and to more schools per children. The resulting distribution of human capital across states persists until today.