It is now well accepted that the gut microbiota contributes to our health. However, what determines the microbiota composition is still unclear. Whereas it might be expected that the intestinal niche would be dominant in shaping the microbiota, studies in vertebrates have repeatedly demonstrated dominant effects of external factors such as host diet and environmental microbial diversity. Hypothesizing that genetic variation may interfere with discerning contributions of host factors, we turned to Caenorhabditis elegans as a new model, offering the ability to work with genetically homogenous populations. Deep sequencing of 16S rDNA was used to characterize the (previously unknown) worm gut microbiota as assembled from diverse produce-enriched soil environments under laboratory conditions. Comparisons of worm microbiotas with those in their soil environment revealed that worm microbiotas resembled each other even when assembled from different microbial environments, and enabled defining a shared core gut microbiota. Community analyses indicated that species assortment in the worm gut was non-random and that assembly rules differed from those in their soil habitat, pointing at the importance of competitive interactions between gut-residing taxa. The data presented fills a gap in C. elegans biology. Furthermore, our results demonstrate a dominant contribution of the host niche in shaping the gut microbiota.