Although commensalism with gut microbiota exists in all metazoans, the host factors that maintain this homeostatic relationship remain largely unknown. We show that the intestinal homeobox gene Caudal regulates the commensal-gut mutualism by repressing nuclear factor kappa B-dependent antimicrobial peptide genes. Inhibition of Caudal expression in flies via RNA interference led to overexpression of antimicrobial peptides, which in turn altered the commensal population within the intestine. In particular, the dominance of one gut microbe, Gluconobacter sp. strain EW707, eventually led to gut cell apoptosis and host mortality. However, restoration of a healthy microbiota community and normal host survival in the Caudal-RNAi flies was achieved by reintroduction of the Caudal gene. These results reveal that a specific genetic deficiency within a host can profoundly influence the gut commensal microbial community and host physiology.