Changes in the microbiota composition are associated with many human diseases, but factors that govern strain abundance remain poorly defined. We show that a commensal Escherichia coli strain and a pathogenic Salmonella enterica serovar Typhimurium isolate both utilize nitrate for intestinal growth, but each accesses this resource in a distinct biogeographical niche. Commensal E. coli utilizes epithelial-derived nitrate, whereas nitrate in the niche occupied by S. Typhimurium is derived from phagocytic infiltrates. Surprisingly, avirulent S. Typhimurium was shown to be unable to utilize epithelial-derived nitrate because its chemotaxis receptors McpB and McpC exclude the pathogen from the niche occupied by E. coli. In contrast, E. coli invades the niche constructed by S. Typhimurium virulence factors and confers colonization resistance by competing for nitrate. Thus, nutrient niches are not defined solely by critical resources, but they can be further subdivided biogeographically within the host into distinct microhabitats, thereby generating new niche opportunities for distinct bacterial species