Why does the severity of parasite infection differ dramatically across habitats? This question remains challenging to answer because multiple correlated pathways drive disease. Here, we examined habitat-disease links through direct effects on parasites and indirect effects on parasite predators (zooplankton), host diversity and key life stages of hosts. We used a case study of amphibian hosts and the chytrid fungus, Batrachochytrium dendrobatidis, in a set of permanent and ephemeral alpine ponds. A field experiment showed that ultraviolet radiation (UVR) killed the free-living infectious stage of the parasite. Yet, permanent ponds with more UVR exposure had higher infection prevalence. Two habitat-related indirect effects worked together to counteract parasite losses from UVR: (i) UVR reduced the density of parasite predators and (ii) permanent sites fostered multi-season host larvae that fuelled parasite production. Host diversity was unlinked to hydroperiod or UVR but counteracted parasite gains; sites with higher diversity of host species had lower prevalence of infection. Thus, while habitat structure explained considerable variation in infection prevalence through two indirect pathways, it could not account for everything. This study demonstrates the importance of creating mechanistic, food web-based links between multiple habitat dimensions and disease.