A growing body of evidence has underscored the role of horizontal gene transfer (HGT) in animal evolution. Previously, we discovered the horizontal transfer of the gene encoding the eukaryotic genotoxin cytolethal distending toxin B (cdtB) from the pea aphid Acyrthosiphon pisum secondary endosymbiont (APSE) phages to drosophilid and aphid nuclear genomes. Here, we report cdtB in the nuclear genome of the gall-forming "swede midge" Contarinia nasturtii (Diptera: Cecidomyiidae) via HGT. We searched all available gall midge genome sequences for evidence of APSE-to-insect HGT events and found five toxin genes (aip56, cdtB, lysozyme, rhs, and sltxB) transferred horizontally to cecidomyiid nuclear genomes. Surprisingly, phylogenetic analyses of HGT candidates indicated APSE phages were often not the ancestral donor lineage of the toxin gene to cecidomyiids. We used a phylogenetic signal statistic to test a transfer-by-proximity hypothesis for animal HGT, which suggested that microbe-to-insect HGT was more likely between taxa that share environments than those from different environments. Many of the toxins we found in midge genomes target eukaryotic cells, and catalytic residues important for toxin function are conserved in insect copies. This class of horizontally transferred, eukaryotic cell-targeting genes is potentially important in insect adaptation.