The discovery of antibiotics more than 80 years ago has led to considerable improvements in human and animal health. Although antibiotic resistance in environmental bacteria is ancient, resistance in human pathogens is thought to be a modern phenomenon that is driven by the clinical use of antibiotics1. Here we show that particular lineages of methicillin-resistant Staphylococcus aureus—a notorious human pathogen—appeared in European hedgehogs in the pre-antibiotic era. Subsequently, these lineages spread within the local hedgehog populations and between hedgehogs and secondary hosts, including livestock and humans. We also demonstrate that the hedgehog dermatophyte Trichophyton erinacei produces two β-lactam antibiotics that provide a natural selective environment in which methicillin-resistant S. aureus isolates have an advantage over susceptible isolates. Together, these results suggest that methicillin resistance emerged in the pre-antibiotic era as a co-evolutionary adaptation of S. aureus to the colonization of dermatophyte-infected hedgehogs. The evolution of clinically relevant antibiotic-resistance genes in wild animals and the connectivity of natural, agricultural and human ecosystems demonstrate that the use of a One Health approach is critical for our understanding and management of antibiotic resistance, which is one of the biggest threats to global health, food security and development.