Diet impacts gut microbes and, subsequently, host immunity, but our understanding of the mechanisms driving this axis remains incomplete. Hattori-Muroi, Maruta, Takahashi, et al. show that dietary soy promotes colonization of commensals that cooperatively induce Tfh cells and polyreactive IgA in Peyer’s patches. This polyreactive IgA maintains gut microbiota homeostasis and confers protection against Salmonella infection.