Although the knowledge of the effects of bacterial colonization on the immune system is rapidly expanding, surprisingly little is known about the immunological mechanisms that shape the intestinal microbial community. Specifically, the complexity of the intestinal microbiota and what constitutes a "healthy" microbial composition has only recently been addressed, facilitated by large-scale metagenomic screens. Containment of such a vast number of different microbes requires tight regulation at the mucosal surface. While beneficial relationships must not be compromised, invading pathogenic bacteria must be dealt with in order to maintain homeostasis. In this review, we will address the latest insights into the role of the mucosal immune system in the control of the microbiota.