How symbiotic lifestyles evolve from free-living ecologies is poorly understood. Novel traits mediating symbioses may stem from preadaptations: features of free-living ancestors that predispose taxa to engage in nascent interspecies relationships. In Metazoa's largest family, Staphylinidae (rove beetles), the body plan within the subfamily Aleocharinae is preadaptive for symbioses with social insects. Short elytra expose a pliable abdomen that bears targetable glands for host manipulation or chemical defense. The exposed abdomen has also been convergently refashioned into ant- and termite-mimicking shapes in multiple symbiotic lineages. Here we show how this preadaptive anatomy evolved via novel Hox gene functions that remodeled the ancestral coleopteran groundplan. Using the model staphylinid Dalotia coriaria, we abolished activities of the five thoracic and abdominal Hox genes. We show that elytral shortening is a staphylinid-specific property of the Hox-less appendage ground state, which is overridden in the metathorax by Ultrabithorax to promote hind wing expansion. In the exposed abdomen, we present evidence that defensive gland development stems from novel combinatorial outputs of the Abdominal-A and Abdominal-B Hox proteins: in the posterior compartment of tergite VI they specify a chemical gland reservoir, an imaginal disc-like invagination of ectodermal secretory cells; in the anterior compartment of tergite VII Abdominal-A and Abdominal-B specify clusters of classical duct-bearing glands. These distinct gland cell types collectively synthesize a blend of benzoquinone irritants, surfactant esters and alkane solvent, a defensive chemistry, which in symbiotic species has been augmented with specialized volatiles that potently manipulate ant behavior. These results reveal how Hox-controlled body axis modifications caused a convergent trend towards evolving symbiosis in the Metazoa