The expansion and intensification of livestock production is predicted to promote the emergence of pathogens. As pathogens sometimes jump between species this can affect the health of humans as well as livestock. Here we investigate how livestock microbiota can act as a source of these emerging pathogens through analysis of Streptococcus suis, a ubiquitous component of the respiratory microbiota of pigs that is also a major cause of disease on pig farms and an important zoonotic pathogen. Combining molecular dating, phylogeography and comparative genomic analyses of a large collection of isolates, we find that several pathogenic lineages of S. suis emerged in the 19th and 20th centuries, during an early period of growth in pig farming. These lineages have since spread between countries and continents, mirroring trade in live pigs. They are distinguished by the presence of three genomic islands with putative roles in metabolism and cell adhesion, and an ongoing reduction in genome size, which may reflect their recent shift to a more pathogenic ecology. Reconstructions of the evolutionary histories of these islands reveal constraints on pathogen emergence that could inform control strategies, with pathogenic lineages consistently emerging from one subpopulation of S. suis and acquiring genes through horizontal transfer from other pathogenic lineages. These results shed light on the capacity of the microbiota to rapidly evolve to exploit changes in their host population and suggest that the impact of changes in farming on the pathogenicity and zoonotic potential of S. suis is yet to be fully realised.