Two closely-related strains of Clostridium difficile became antibiotic resistant and were able to rapidly spread to hospitals around the world, a study says.
Researchers were able to show how the bacterium travelled by forensically analysing its genetic code.
The strains of the hospital infection seemed to become more severe after they became resistant.
The findings were published in the journal Nature Genetics.
The US Centers for Disease Control say C. difficile is linked to 14,000 deaths in the US each year.
The infection has been in hospitals for decades. However, there was growing concern in the last decade after large outbreaks in Europe, the US and Canada.
They were caused by a once rare variant of C. difficile which has become the most common cause of the infection in North America. Tracking
The genetic code of C. difficile mutates rapidly. By comparing the genetic code of batches of C. difficile, researchers can work out how related different batches of C. difficile are.
Doing this on a large scale, involving 151 samples from infections in 19 countries, allowed researchers to build up a picture of the spread of the antibiotic resistant strains.
It showed there was an strain called FQR1 which started in the US and spread across the country and to Switzerland and South Korea.
A second strain FQR2 started in Canada before spreading across North America, Europe and Australia. It entered the UK on four separate occasions.
Dr Trevor Lawley, from the Wellcome Trust Sanger Institute, told the BBC: "If we can understand how it happened there are lessons in that. It's a fact that two strains emerged which tells us this is more frequent than we realise and it is driven by antibiotic resistance.
"It also shows the global healthcare systems are completely interlinked - it showed up in the UK within months."
Prof Brendan Wren, from the London School of Hygiene and Tropical Medicine, has been studying C. difficile for 25 years.
He said: "Once it became fluoroquinolone resistant, it just seemed to become more severe and transmissible."
"Not only is [the antibiotic] virtually useless against this organism, but resistance seem to have been a major factor in the continued evolution and persistence of these strains in hospitals and clinical settings."
The cost and time taken to sequencing the whole genome of a bacterium has plummeted. It took less than a day at a cost of £40-60.
The hope is that in the future researchers will be able to monitor the spread of diseases while outbreaks are happening as well as getting a better understanding of the disease and how to stop it.