Inherited immunity is an emerging field and describes how the transfer of immunity from parents to offspring can promote progeny survival in the face of infection. The mechanisms of how inherited immunity is induced are mostly unknown. The intracellular parasite Nematocida parisii is a natural microsporidian pathogen of Caenorhabditis elegans. Here, we show that N. parisii-infected worms produce primed offspring that are resistant to microsporidia infection. We find that immunity is induced in a dose dependent manner and lasts for a single generation. Intergenerational immunity prevents host cell invasion by N. parisii and also enhances survival to the bacterial pathogen Pseudomonas aeruginosa. Further, we show that inherited immunity is triggered by the host transcriptional response to infection, which can also be induced through maternal somatic depletion of negative regulators PALS-22 and the retinoblastoma protein ortholog LIN-35. We show that other biotic and abiotic stresses, such as viral infection and cadmium exposure, that induce a similar transcriptional response to microsporidia can also induce immunity in progeny. Our results demonstrate that distinct stimuli can induce inherited immunity to provide resistance against multiple classes of pathogens. These results show that activation of an innate immune response can provide protection against pathogens not only within a generation, but also in the next generation.