The succession from aerobic and facultative anaerobic bacteria to obligate anaerobes in the infant gut along with the differences between the compositions of the mucosally adherent vs. luminal microbiota suggests that the gut microbes consume oxygen, which diffuses into the lumen from the intestinal tissue, maintaining the lumen in a deeply anaerobic state. Remarkably, measurements of luminal oxygen levels show nearly identical pO (partial pressure of oxygen) profiles in conventional and germ-free mice, pointing to the existence of oxygen consumption mechanisms other than microbial respiration. In vitro experiments confirmed that the luminal contents of germ-free mice are able to chemically consume oxygen (e.g., via lipid oxidation reactions), although at rates significantly lower than those observed in the case of conventionally housed mice. For conventional mice, we also show that the taxonomic composition of the gut microbiota adherent to the gut mucosa and in the lumen throughout the length of the gut correlates with oxygen levels. At the same time, an increase in the biomass of the gut microbiota provides an explanation for the reduction of luminal oxygen in the distal vs. proximal gut. These results demonstrate how oxygen from the mammalian host is used by the gut microbiota, while both the microbes and the oxidative chemical reactions regulate luminal oxygen levels, shaping the composition of the microbial community throughout different regions of the gut.