Inherited microorganisms can selfishly manipulate host reproduction to drive through populations. In Drosophila melanogaster, germline expression of the native prophage WO proteins CifA and CifB cause cytoplasmic incompatibility (CI) in which sperms fertilize uninfected embryos that suffer catastrophic mitotic defects and lethality; however in infected females, CifA rescues the embryonic lethality and thus imparts a fitness advantage to Wolbachia. Despite widespread relevance to sex determination, evolution, and vector control, the mechanisms underlying when and how CI impairs male reproduction remain unknown and a topic of debate. Here we use cytochemical, microscopic, and transgenic assays in D. melanogaster to demonstrate that CifA and CifB proteins of wMel localize to nuclear DNA throughout the process of spermatogenesis. Cif proteins cause abnormal histone retention in elongating spermatids and protamine deficiency in mature sperms of CI-causing males. Protamine-deficient sperms travel to the female reproductive tract together with Cif proteins. In female ovaries, CifA localizes to germ cell nuclei and overlaps with Wolbachia in the nurse cell cytoplasm and the oocyte, however Cifs are not present in late-stage oocytes and the embryo. Moreover, CI and rescue are contingent upon a newly annotated CifA bipartite nuclear localization sequence. Our results reveal a previously unrecognized phenomena in which prophage proteins invade animal gametic nuclei and modify the histone-protamine transition of spermatogenesis.