The immune system responds vigorously to microbial infection while permitting lifelong colonization by the microbiome. Mechanisms that facilitate the establishment and stability of the gut microbiota remain poorly described. We found that a regulatory system in the prominent human commensal Bacteroides fragilis modulates its surface architecture to invite binding of immunoglobulin A (IgA) in mice. Specific immune recognition facilitated bacterial adherence to cultured intestinal epithelial cells and intimate association with the gut mucosal surface in vivo. The IgA response was required for B. fragilis (and other commensal species) to occupy a defined mucosal niche that mediates stable colonization of the gut through exclusion of exogenous competitors. Therefore, in addition to its role in pathogen clearance, we propose that IgA responses can be co-opted by the microbiome to engender robust host-microbial symbiosis.