Cooperation based on the production of costly common goods is observed throughout nature. This is puzzling, as cooperation is vulnerable to exploitation by defectors which enjoy a fitness advantage by consuming the common good without contributing fairly. Depletion of the common good can lead to population collapse and the destruction of cooperation. However, population collapse implies small population size, which, in a structured population, is known to favor cooperation. This happens because small population size increases variability in cooperator frequency across different locations. Since individuals in cooperator-dominated locations (which are most likely cooperators) will grow more than those in defector-dominated locations (which are most likely defectors), cooperators can outgrow defectors globally despite defectors outgrowing cooperators in each location. This raises the possibility that defectors can lead to conditions that sometimes rescue cooperation from defector-induced destruction. We demonstrate multiple mechanisms through which this can occur, using an individual-based approach to model stochastic birth, death, migration, and mutation events. First, during defector-induced population collapse, defectors occasionally go extinct before cooperators by chance, which allows cooperators to grow. Second, empty locations, either preexisting or created by defector-induced population extinction, can favor cooperation because they allow cooperator but not defector migrants to grow. These factors lead to the counterintuitive result that the initial presence of defectors sometimes allows better survival of cooperation compared to when defectors are initially absent. Finally, we find that resource limitation, inducible by defectors, can select for mutations adaptive to resource limitation. When these mutations are initially present at low levels or continuously generated at a moderate rate, they can favor cooperation by further reducing local population size. We predict that in a structured population, small population sizes precipitated by defectors provide a “built-in” mechanism for the persistence of cooperation.