Spatial structuring is important for the maintenance of natural ecological systems1,2. Many microbial communities, including the gut microbiome, display intricate spatial organization3-9. Mapping the biogeography of bacteria can shed light on interactions that underlie community functions10-12, but existing methods cannot accommodate the hundreds of species that are found in natural microbiomes13-17. Here we describe metagenomic plot sampling by sequencing (MaPS-seq), a culture-independent method to characterize the spatial organization of a microbiome at micrometer-scale resolution. Intact microbiome samples are immobilized in a gel matrix and cryofractured into particles. Neighboring microbial taxa in the particles are then identified by droplet-based encapsulation, barcoded 16S rRNA amplification and deep sequencing. Analysis of three regions of the mouse intestine revealed heterogeneous microbial distributions with positive and negative co-associations between specific taxa. We identified robust associations between Bacteroidales taxa in all gut compartments and showed that phylogenetically clustered local regions of bacteria were associated with a dietary perturbation. Spatial metagenomics could be used to study microbial biogeography in complex habitats.