Positive selection in the two-domain type 1 pilus adhesin FimH enhances Escherichia coli fitness in urinary tract infection (UTI). We report a comprehensive atomic-level view of FimH in two-state conformational ensembles in solution, composed of one low-affinity tense (T) and multiple high-affinity relaxed (R) conformations. Positively selected residues allosterically modulate the equilibrium between these two conformational states, each of which engages mannose through distinct binding orientations. A FimH variant that only adopts the R state is severely attenuated early in a mouse model of uncomplicated UTI but is proficient at colonizing catheterized bladders in vivo or bladder transitional-like epithelial cells in vitro. Thus, the bladder habitat has barrier(s) to R state–mediated colonization possibly conferred by the terminally differentiated bladder epithelium and/or decoy receptors in urine. Together, our studies reveal the conformational landscape in solution, binding mechanisms, and adhesive strength of an allosteric two-domain adhesin that evolved “moderate” affinity to optimize persistence in the bladder during UTI.