We develop a dynamic discrete choice model of a self-interested and unchecked ruler making decisions regarding the exploitation of a resource-rich country. This dictator makes the recursive choice between either investing domestically to live off the productivity of the country while facing the risk of being ousted, or looting the country's riches by liquefying the resources and departing. We demonstrate that important parameters determining this choice include the level of resources, liquidity and indebtedness. We find that the dictator's choice regarding the timing of departure is significantly related to external lending, investment and debt. We then argue that this looting phenomenon provides an explanation for the generation of corrupt economies in resource-rich countries. An empirical analysis of available corruption indices suggests that instability-led looting provides a more fundamental explanation of perceived corruption than do various social and cultural indicators or the economic theory of internal political competition.