A central process in evolution is the recruitment of genes to regulatory networks. We engineered immotile strains of the bacterium Pseudomonas fluorescens that lack flagella due to deletion of the regulatory gene fleQ. Under strong selection for motility, these bacteria consistently regained flagella within 96 hours via a two-step evolutionary pathway. Step 1 mutations increase intracellular levels of phosphorylated NtrC, a distant homolog of FleQ, which begins to commandeer control of the fleQ regulon at the cost of disrupting nitrogen uptake and assimilation. Step 2 is a switch-of-function mutation that redirects NtrC away from nitrogen uptake and toward its novel function as a flagellar regulator. Our results demonstrate that natural selection can rapidly rewire regulatory networks in very few, repeatable mutational steps.