Endogenous viral elements are increasingly found in eukaryotic genomes, yet little is known about their origins, dynamics, or function. Here, we provide a compelling example of a DNA virus that readily integrates into a eukaryotic genome where it acts as an inducible antiviral defense system. We found that the virophage mavirus, a parasite of the giant virus CroV, integrates at multiple sites within the nuclear genome of the marine heterotrophic nanoflagellate Cafeteria roenbergensis. The endogenous mavirus is structurally and genetically similar to the eukaryotic Maverick/Polinton DNA transposons. Provirophage genes are activated by superinfection with CroV, which leads to the production of infectious mavirus particles. While provirophage-carrying cells are not directly protected from lysis by CroV, release of reactivated virophage particles promotes survival of other host populations. Our results corroborate the connection between mavirus and Maverick/Polinton elements and suggest that provirophages can defend natural protist populations against infection by giant viruses.