The phase variation of type 1 fimbriae in Escherichia coli is associated with the site-specific inversion of a short DNA element. Recombination at fim requires fimB and fimE, and their products are considered to be the fim recombinases. In this study, FimB and FimE were overproduced and extracts containing the proteins were shown to (i) bind to and (ii) invert the fim switch in vitro. Phenanthroline-copper protection of DNA-protein complexes showed that both FimB and FimE bind to half-sites that flank, and overlap with, the left and right inverted repeats (IRL and IRR, respectively) of the fim switch. Alignment of the four half-sites identified a conserved 5'-CA doublet; mutation of these two bases lowers the affinity of binding of both FimB and FimE to the inverted repeats, and greatly diminishes inversion of the fim switch in vivo. The specificity of the fim recombinases observed in vivo (FimB switching in both directions; FimE switching from on-to-off only) was maintained in vitro. Furthermore, the different binding affinities of FimB and FimE for the various half-site combinations suggests that the specificity of FimE could arise, in part, from the low affinity of FimE for IRL (off).