It has been proposed that capacity to generate variation can evolve by natural selection such that mutation becomes biased toward adaptive outcomes. However the idea that selection might drive the evolution of evolvability has remained largely theoretical. Here we detail the de novo evolution of evolvability in experimental populations of bacteria, making explicit the selective processes and molecular events. Key to experimental realisation was a lineage-level birth-death dynamic, where lineage reproductive success was dependent upon capacity to mutate between two target phenotypic states, each optima in a repeating cycle of environments. Fueled by variation in evolutionary potential associated with unique mutational paths, lineages capable of mediating rapid and reliable transitions between states through local mutational bias emerged. The mechanism is analogous to that underpinning highly mutable "contingency loci" in pathogenic bacteria. Drawing upon detailed knowledge of the evolutionary history of lineages, we identify key steps in construction of the locus, including changes to the genotype-phenotype map and input from mutations that elevated transcription and concomitantly, rates of localised frame-shifting. We also document ancillary advantages to rapid phenotype switching, with lineages possessing this ability being more likely to acquire secondary adaptive mutations. Our results provide a mechanistic account of a previously puzzling evolutionary phenomenon and clarify conditions for the adaptive evolution of evolvability.