Although horizontal gene transfer is pervasive in the intestinal microbiota, we understand only superficially the roles of most exchanged genes and how the mobile repertoire affects community dynamics. Similarly, little is known about the mechanisms underlying the ability of a community to recover after a perturbation. Here, we identified and functionally characterized a large conjugative plasmid that is one of the most frequently transferred elements among Bacteroidales species and is ubiquitous in diverse human populations. This plasmid encodes both an extracellular polysaccharide and fimbriae, which promote the formation of multispecies biofilms in the mammalian gut. We use a hybridization-based approach to visualize biofilms in clarified whole colon tissue with unprecedented 3D spatial resolution. These biofilms increase bacterial survival to common stressors encountered in the gut, increasing strain resiliency, and providing a rationale for the plasmid's recent spread and high worldwide prevalence.