Understanding how environmental fluctuations affect population persistence is essential for predicting the ecological impacts of expected future increases in climate variability. However, two bodies of theory make opposite predictions about the effect of environmental variation on persistence. Single-species theory, common in conservation biology and population viability analyses, suggests that environmental variation increases the risk of stochastic extinction. By contrast, coexistence theory has shown that environmental variation can buffer inferior competitors against competitive exclusion through a storage effect. We reconcile these two perspectives by showing that in the presence of demographic stochasticity, environmental variation can increase the chance of extinction while simultaneously stabilizing coexistence. Our stochastic simulations of a two-species storage effect model reveal a unimodal relationship between environmental variation and coexistence time, implying maximum coexistence at intermediate levels of environmental variation. The unimodal pattern reflects the fact that the stabilizing influence of the storage effect accumulates rapidly at low levels of environmental variation, whereas the risk of extinction due to the combined effects of environmental variation and demographic stochasticity increases most rapidly at higher levels of variation. Future increases in environmental variation could either increase or decrease an inferior competitor's expected persistence time, depending on the distance between the present level of environmental variation and the optimal level anticipated by this theory.