Emerging zoonoses threaten global health, yet the processes by which they emerge are complex and poorly understood. Nipah virus (NiV) is an important threat owing to its broad host and geographical range, high case fatality, potential for human-to-human transmission and lack of effective prevention or therapies. Here, we investigate the origin of the first identified outbreak of NiV encephalitis in Malaysia and Singapore. We analyse data on livestock production from the index site (a commercial pig farm in Malaysia) prior to and during the outbreak, on Malaysian agricultural production, and from surveys of NiV's wildlife reservoir (flying foxes). Our analyses suggest that repeated introduction of NiV from wildlife changed infection dynamics in pigs. Initial viral introduction produced an explosive epizootic that drove itself to extinction but primed the population for enzootic persistence upon reintroduction of the virus. The resultant within-farm persistence permitted regional spread and increased the number of human infections. This study refutes an earlier hypothesis that anomalous El Niño Southern Oscillation-related climatic conditions drove emergence and suggests that priming for persistence drove the emergence of a novel zoonotic pathogen. Thus, we provide empirical evidence for a causative mechanism previously proposed as a precursor to widespread infection with H5N1 avian influenza and other emerging pathogens.