Intestinal homeostasis is critical for efficient energy extraction from food and protection from pathogens. Its disruption can lead to an array of severe illnesses with major impacts on public health, such as inflammatory bowel disease characterized by self-destructive intestinal immunity. However, the mechanisms regulating the equilibrium between the large bacterial flora and the immune system remain unclear. Intestinal lymphoid tissues generate flora-reactive IgA-producing B cells, and include Peyer's patches and mesenteric lymph nodes, as well as numerous isolated lymphoid follicles (ILFs). Here we show that peptidoglycan from Gram-negative bacteria is necessary and sufficient to induce the genesis of ILFs in mice through recognition by the NOD1 (nucleotide-binding oligomerization domain containing 1) innate receptor in epithelial cells, and beta-defensin 3- and CCL20-mediated signalling through the chemokine receptor CCR6. Maturation of ILFs into large B-cell clusters requires subsequent detection of bacteria by toll-like receptors. In the absence of ILFs, the composition of the intestinal bacterial community is profoundly altered. Our results demonstrate that intestinal bacterial commensals and the immune system communicate through an innate detection system to generate adaptive lymphoid tissues and maintain intestinal homeostasis.