In this paper we show that states form to overcome the adverse effects of environmental change. In a panel dataset of settlement, state formation, and public good provision in southern Iraq between 5000BCE and today, we estimate the effect of a series of river shifts. We hypothesize that a river shift creates a collective action problem in communally organizing irrigation, and creates demand for a state. We show four main results. First, a river shift negatively affects settlement density, and therefore incentivizes canal irrigation. Second, a river shift leads to state formation, centralization of existing states, and the construction of administrative buildings. Third, these states raise taxes, and build canals to replace river irrigation. Finally, where canals are built, river shifts no longer negatively affect settlement. Our results support a social contract theory of state formation: citizens faced with a collective action problem exchange resources and autonomy for public good provision.