Both the ecological adaptations of an organism and its evolutionary history are recorded in a genome. We used Agrobacterium biovar 1, a diverse group of plant-associated bacteria as a model to search for genomic signatures of ecological adaptation in relation to diversification. We designed a new phylogenetic approach accounting for horizontal transfer and duplication to reconstruct the evolutionary history of Agrobacterium genomes and infer ancestral gene contents. We find that allowing for genes to be co-transferred and co-duplicated significantly improves scenarios of genome evolution. Most genes acquired before the diversification of major clades within Agrobacterium are organized in blocks of co-evolving genes encoding coherent pathways. This pattern of gene co-evolution rejects a neutral model of transfer, in which neighbouring genes would be transferred independently of their function. In addition, the conservation of acquired genes is driven by purifying selection on collectively coded functions. Based on this criterion, we identify the genomic determinants of ecological niche diversification within this group. The strong selective role of host plant rhizospheres in the history of Agrobacterium is evident from the recurrent acquisition of functions involved in the production of secreted secondary metabolites or extracellular matrix, and in the metabolism of plant-derived compounds such as phenolics and amino-acids. Our reconstructed genome history – from single gene trees with transfer and duplication events to blocks of co-evolved genes and functional annotations, etc. – is compiled in an integrative database, Agrogenom, which can be visualized and queried through an interactive web interface accessible at http://phylariane.univ-lyon1.fr/db/agrogenom/3.