Epithelial surfaces of most animals are colonized by diverse microbial communities. Although it is generally agreed that commensal bacteria can serve beneficial functions, the processes involved are poorly understood. Here we report that in the basal metazoan Hydra, ectodermal epithelial cells are covered with a multilayered glycocalyx that provides a habitat for a distinctive microbial community. Removing this epithelial microbiota results in lethal infection by the filamentous fungus Fusarium sp. Restoring the complex microbiota in gnotobiotic polyps prevents pathogen infection. Although mono-associations with distinct members of the microbiota fail to provide full protection, additive and synergistic interactions of commensal bacteria are contributing to full fungal resistance. Our results highlight the importance of resident microbiota diversity as a protective factor against pathogen infections. Besides revealing insights into the in vivo function of commensal microbes in Hydra, our findings indicate that interactions among commensal bacteria are essential to inhibit pathogen infection.