The diverse bacterial populations that comprise the commensal microbiome of the human intestine play a central role in health and disease. A method that sustains complex microbial communities in direct contact with living human intestinal cells and their overlying mucus layer in vitro would thus enable investigations of host–microbiome interactions. Here, we show the extended co-culture of living human intestinal epithelium with stable communities of aerobic and anaerobic human gut microbiota, enabled by a microfluidic intestine-on-a-chip that permits the control and real-time assessment of physiologically relevant oxygen gradients. When compared to aerobic co-culture conditions, the establishment of a transluminal hypoxia gradient in the chip increased intestinal barrier function and sustained a physiologically relevant level of microbial diversity, consisting of over 200 unique operational taxonomic units from 11 different genera, and of an abundance of obligate anaerobic bacteria with ratios of Firmicutes and Bacteroidetes similar to those observed in human faeces. The intestine-on-a-chip may serve as a discovery tool for the development of microbiome-related therapeutics, probiotics and nutraceuticals.