Diverse animals across the tree of life undergo the life-history transition of metamorphosis in response to bacteria. Although immunity has been implicated in this metamorphosis in response to bacteria, no functional connection has yet been demonstrated between immunity and metamorphosis. We investigated a host–microbe interaction involving a marine tubeworm, Hydroides elegans , that undergoes metamorphosis in response to Pseudoalteromonas luteoviolacea , a metamorphosis-inducing marine bacterium. By creating a marine bacteria–mediated RNA interference approach, we show that myeloid differentiation factor 88 (MyD88), a critical immune adaptor for Toll-like receptor and interleukin pathways, is necessary for the stimulation of metamorphosis in response to bacteria. In addition to a developmental role, we show that MyD88 is necessary for survival during exposure to the bacterial pathogen Pseudomonas aeruginosa , showing that Hydroides utilizes MyD88 during both development and an immune response. These results provide a functional characterization of the innate immune system involved in an animal's metamorphosis.