The Mexican prairie dog Cynomys mexicanus is an endemic burrowing rodent with a restricted distribution. Up to 1996 the species experienced a loss of c. 60% of its historical range, and in the last few years a further loss of habitat has occurred, with the current range now covering only 36% of the historical range. In this study we examined the population dynamics of the Mexican prairie dog to determine the relative effects of habitat loss, isolation of remaining colonies, and decreasing habitat quality. We used data on prairie dog numbers in all colonies and demographic data for two colonies to carry out a stochastic population viability analysis. We found differing vital rates, which are presumed to result from differing habitat quality, at two colonies. As small variations of vital rates in the model strongly influenced the extinction risk for small populations, we conclude that habitat quality is important for the small populations. In the model the Los Angeles complex of colonies experienced a low risk of local extinction whereas at the Manantial complex local extinctions were frequent. Scenarios with changes in population sizes had the largest effect on extinction risk. Differing migration scenarios had little impact on extinction risk.