Compartmentalization of the gut microbiota is thought to be important to system function, but the extent of spatial organization in the gut ecosystem remains poorly understood. Here, we profile the murine colonic microbiota along longitudinal and lateral axes using laser capture microdissection. We found fine-scale spatial structuring of the microbiota marked by gradients in composition and diversity along the length of the colon. Privation of fiber reduces the diversity of the microbiota and disrupts longitudinal and lateral gradients in microbiota composition. Both mucus-adjacent and luminal communities are influenced by the absence of dietary fiber, with the loss of a characteristic distal colon microbiota and a reduction in the mucosa-adjacent community, concomitant with depletion of the mucus layer. These results indicate that diet has not only global but also local effects on the composition of the gut microbiota, which may affect function and resilience differently depending on location.