Ecological transitions between different lifestyles, such as pathogenicity, mutualism and saprophytism, have been very frequent in the course of microbial evolution, and often driven by horizontal gene transfer. Yet, how genomes achieve the ecological transition initiated by the transfer of complex biological traits remains poorly known. Here, we used experimental evolution, genomics, transcriptomics and high-resolution phenotyping to analyze the evolution of the plant pathogen Ralstonia solanacearum into legume symbionts, following the transfer of a natural plasmid encoding the essential mutualistic genes. We show that a regulatory pathway of the recipient R. solanacearum genome involved in extracellular infection of natural hosts was reused to improve intracellular symbiosis with the Mimosa pudica legume. Optimization of intracellular infection capacity was gained through mutations affecting two components of a new regulatory pathway, the transcriptional regulator efpR and a region upstream from the RSc0965–0967 genes of unknown functions. Adaptive mutations caused the downregulation of efpR and the over-expression of a downstream regulatory module, the three unknown genes RSc3146–3148, two of which encoding proteins likely associated to the membrane. This over-expression led to important metabolic and transcriptomic changes and a drastic qualitative and quantitative improvement of nodule intracellular infection. In addition, these adaptive mutations decreased the virulence of the original pathogen. The complete efpR/RSc3146–3148 pathway could only be identified in the genomes of the pathogenic R. solanacearum species complex. These findings illustrate how the rewiring of a genetic network regulating virulence allows a radically different type of symbiotic interaction and contributes to ecological transitions and trade-offs.