Background Since 2013, over 100 cases of Mycobacterium chimaera prosthetic valve endocarditis and disseminated disease were notified in Europe and the USA, linked to contaminated heater–cooler units (HCUs) used during cardiac surgery. We did a molecular epidemiological investigation to establish the source of these patients' disease. Methods We included 24 M chimaera isolates from 21 cardiac surgery-related patients in Switzerland, Germany, the Netherlands, and the UK, 218 M chimaera isolates from various types of HCUs in hospitals, from LivaNova (formerly Sorin; London, UK) and Maquet (Rastatt, Germany) brand HCU production sites, and unrelated environmental sources and patients, as well as eight Mycobacterium intracellulare isolates. Isolates were analysed by next-generation whole-genome sequencing using Illumina and Pacific Biosciences technologies, and compared with published M chimaera genomes. Findings Phylogenetic analysis based on whole-genome sequencing of 250 isolates revealed two major M chimaera groups. Cardiac surgery-related patient isolates were all classified into group 1, in which all, except one, formed a distinct subgroup. This subgroup also comprised isolates from 11 cardiac surgery-related patients reported from the USA, most isolates from LivaNova HCUs, and one from their production site. Isolates from other HCUs and unrelated patients were more widely distributed in the phylogenetic tree. Interpretation HCU contamination with M chimaera at the LivaNova factory seems a likely source for cardiothoracic surgery-related severe M chimaera infections diagnosed in Switzerland, Germany, the Netherlands, the UK, the USA, and Australia. Protective measures and heightened clinician awareness are essential to guarantee patient safety. Funding Partly funded by the EU Horizon 2020 programme, its FP7 programme, the German Center for Infection Research (DZIF), the Swiss National Science Foundation, the Swiss Federal Office of Public Health, and National Institute of Health Research Oxford Health Protection Research Units on Healthcare Associated Infection and Antimicrobial Resistance.