Environmental variability can promote species diversity when species respond differently to environmental conditions, via the storage effect. Pathogens, predators and other shared consumers can also facilitate coexistence when they differentially limit common species. However, it remains unclear how environmental variation and consumers interact to determine species diversity. Here, I use a model based on California annual grassland plants to show that a generalist pathogen with no host specificity can enhance the positive effect of environmental variability on diversity. The model predicts that pathogens can promote diversity by increasing the covariance between the environment and competition, enhancing the storage effect. However, pathogen impacts depend on life history. Pathogens that infect germinating seeds or plants tend to increase the storage effect, whereas those that infect dormant seeds can undermine the storage effect by eliminating population buffering during unfavorable years. These results suggest that pathogens may mediate plant responses to environmental variability and change, and in doing so may maintain diversity.