Bacteria coordinate expression of virulence determinants in response to localized microenvironments in their hosts. Here we show that Shigella flexneri, which causes dysentery, encounters varying oxygen concentrations in the gastrointestinal tract, which govern activity of its type three secretion system (T3SS). The T3SS is essential for cell invasion and virulence. In anaerobic environments (for example, the gastrointestinal tract lumen), Shigella is primed for invasion and expresses extended T3SS needles while reducing Ipa (invasion plasmid antigen) effector secretion. This is mediated by FNR (fumarate and nitrate reduction), a regulator of anaerobic metabolism that represses transcription of spa32 and spa33, virulence genes that regulate secretion through the T3SS. We demonstrate there is a zone of relative oxygenation adjacent to the gastrointestinal tract mucosa, caused by diffusion from the capillary network at the tips of villi. This would reverse the anaerobic block of Ipa secretion, allowing T3SS activation at its precise site of action, enhancing invasion and virulence.