Iron is critical in host-microbe interactions, and its availability is under tight regulation in the mammalian gut. Antibiotics and inflammation are known to perturb iron availability in the gut, which could subsequently alter host-microbe interactions. Here, we show that an adaptive allele of iscR, encoding a major regulator of iron homeostasis of Escherichia coli, is under fluctuating selection in the mouse gut. In vivo competitions in immune-competent, immune-compromised, and germ-free mice reveal that the selective pressure on an iscR mutant E. coli is modulated by the presence of antibiotics, other members of the microbiota, and the immune system. In vitro assays show that iron availability is an important mediator of the iscR allele fitness benefits or costs. We identify Lipocalin-2, a host's innate immune system protein that prevents bacterial iron acquisition, as a major host mechanism underlying fluctuating selection of the iscR allele. Our results provide a remarkable example of strong fluctuating selection acting on bacterial iron regulation in the mammalian gut.