Distinct niches of the mammalian gut are populated by diverse microbiota, but the contribution of spatial variation to intestinal metabolism remains unclear. Here we present a map of the longitudinal metabolome along the gut of healthy colonized and germ-free male mice. With this map, we reveal a general shift from amino acids in the small intestine to organic acids, vitamins and nucleotides in the large intestine. We compare the metabolic landscapes in colonized versus germ-free mice to disentangle the origin of many metabolites in different niches, which in some cases allows us to infer the underlying processes or identify the producing species. Beyond the known impact of diet on the small intestinal metabolic niche, distinct spatial patterns suggest specific microbial influence on the metabolome in the small intestine. Thus, we present a map of intestinal metabolism and identify metabolite–microbe associations, which provide a basis to connect the spatial occurrence of bioactive compounds to host or microorganism metabolism.