Abstract Background The interaction of organisms with their surrounding microbial communities influences many biological processes, a notable example of which is the shaping of the immune system in early life. In the Pacific oyster, Crassostrea gigas, the role of the environmental microbial community on immune system maturation — and, importantly, protection from infectious disease — is still an open question. Results Here, we demonstrate that early life microbial exposure durably improves oyster survival when challenged with the pathogen causing Pacific oyster mortality syndrome (POMS), both in the exposed generation and in the subsequent one. Combining microbiota, transcriptomic, genetic, and epigenetic analyses, we show that the microbial exposure induced changes in epigenetic marks and a reprogramming of immune gene expression leading to long-term and intergenerational immune protection against POMS. Conclusions We anticipate that this protection likely extends to additional pathogens and may prove to be an important new strategy for safeguarding oyster aquaculture efforts from infectious disease. tag the videobyte/videoabstract in this section Video Abstract