By determining susceptibility to disease, environment-driven variation in immune responses can affect the health, productivity and fitness of vertebrates. Yet how the different components of the total environment control this immune variation is remarkably poorly understood. Here, through combining field observation, experimentation and modelling, we are able to quantitatively partition the key environmental drivers of constitutive immune allocation in a model wild vertebrate (three-spined stickleback, Gasterosteus aculeatus). We demonstrate that, in natural populations, thermal conditions and diet alone are sufficient (and necessary) to explain a dominant (seasonal) axis of variation in immune allocation. This dominant axis contributes to both infection resistance and tolerance and, in turn, to the vital rates of infectious agents and the progression of the disease they cause. Our results illuminate the environmental regulation of vertebrate immunity (given the evolutionary conservation of the molecular pathways involved) and they identify mechanisms through which immunocompetence and host-parasite dynamics might be impacted by changing environments. In particular, we predict a dominant sensitivity of immunocompetence and immunocompetence-driven host-pathogen dynamics to host diet shifts.