Pathogens often exert strong selection, yet host populations maintain considerable genetic variation for resistance, possibly due to environmental heterogeneity causing fitness trade-offs. These trade-offs could help explain genetic variation for pathogen defence, and also constrain resistance evolution to microbial pesticides (an underappreciated risk). However, the presence and strength of such trade-offs remain unclear. We investigate whether pathogen identity or host diet has a stronger effect on the fitness of resistance alleles. We quantify genetic variation and covariation for pathogen resistance in an insect pest across distinct pathogen and plant diet combinations. We demonstrate substantial heritability, indicating considerable risks of biopesticide resistance. Contrary to conventional thinking in host-pathogen biology, we found no strong genetic trade-offs for resisting two fungal pathogen species, but changes in plant diet dramatically altered selection for resistance, revealing diet-mediated genetic trade-offs affecting pest survival. Our data suggest that trade-offs not strictly related to immunocompetence could nevertheless maintain genetic variation for pathogen defence in natural and agricultural landscapes.