Eukaryotes engage in a multitude of beneficial and deleterious interactions with bacteria. Hamiltonella defensa, an endosymbiont of aphids and other sap-feeding insects, protects its aphid host from attack by parasitoid wasps. Thus H. defensa is only conditionally beneficial to hosts, unlike ancient nutritional symbionts, such as Buchnera, that are obligate. Similar to pathogenic bacteria, H. defensa is able to invade naive hosts and circumvent host immune responses. We have sequenced the genome of H. defensa to identify possible mechanisms that underlie its persistence in healthy aphids and protection from parasitoids. The 2.1-Mb genome has undergone significant reduction in size relative to its closest free-living relatives, which include Yersinia and Serratia species (4.6-5.4 Mb). Auxotrophic for 8 of the 10 essential amino acids, H. defensa is reliant upon the essential amino acids produced by Buchnera. Despite these losses, the H. defensa genome retains more genes and pathways for a variety of cell structures and processes than do obligate symbionts, such as Buchnera. Furthermore, putative pathogenicity loci, encoding type-3 secretion systems, and toxin homologs, which are absent in obligate symbionts, are abundant in the H. defensa genome, as are regulatory genes that likely control the timing of their expression. The genome is also littered with mobile DNA, including phage-derived genes, plasmids, and insertion-sequence elements, highlighting its dynamic nature and the continued role horizontal gene transfer plays in shaping it.