Host plant chemical composition critically shapes the performance of insect herbivores feeding on them. Some insects have become specialized on plant secondary metabolites, and even use them to their own advantage such as defense against predators. However, infection by plant pathogens can seriously alter the interaction between herbivores and their host plants. We tested whether the effects of the plant secondary metabolites, iridoid glycosides (IGs), on the performance and immune response of an insect herbivore are modulated by a plant pathogen. We used the IG‐specialized Glanville fritillary butterfly Melitaea cinxia, its host plant Plantago lanceolata, and the naturally occurring plant pathogen, powdery mildew Podosphaera plantaginis, as model system. Pre‐diapause larvae were fed on P. lanceolata host plants selected to contain either high or low IGs, in the presence or absence of powdery mildew. Larval performance was measured by growth rate, survival until diapause, and by investment in immunity. We assessed immunity after a bacterial challenge in terms of phenoloxidase (PO) activity and the expression of seven pre‐selected insect immune genes (qPCR). We found that the beneficial effects of constitutive leaf IGs, that improved larval growth, were significantly reduced by mildew infection. Moreover, mildew presence downregulated one component of larval immune response (PO activity), suggesting a physiological cost of investment in immunity under suboptimal conditions. Yet, feeding on mildew‐infected leaves caused an upregulation of two immune genes, lysozyme and prophenoloxidase. Our findings indicate that a plant pathogen can significantly modulate the effects of secondary metabolites on the growth of an insect herbivore. Furthermore, we show that a plant pathogen can induce contrasting effects on insect immune function. We suspect that the activation of the immune system toward a plant pathogen infection may be maladaptive, but the actual infectivity on the larvae should be tested.