Maternally transmitted endosymbionts are widespread among insects, but how they are maintained within host populations is largely unknown. Recent discoveries show that some endosymbionts protect their hosts from pathogens or parasites. Spiroplasma, an endosymbiont of Drosophila neotestacea, protects female hosts from the sterilizing effects of parasitism by the nematode Howardula aoronymphium. Here, we show that Spiroplasma spreads rapidly within experimental populations of D. neotestacea subject to Howardula parasitism, but is neither strongly favored nor selected against in the absence of Howardula. In a reciprocal experiment, Howardula declined steadily to extinction in populations of Spiroplasma-infected flies, whereas in populations of uninfected flies, the prevalence of Howardula parasitism increased to c. 100%. Thus, Spiroplasma and Howardula exhibit effectively consumer-resource trophic dynamics. The recent spread of Spiroplasma in natural populations of D. neotestacea coincides with a decline in the prevalence of Howardula parasitism in the wild.