A superbug with resistance to virtually all known antibiotics gained its power by hijacking genes from other bugs.
Staph bacteria (picture courtesy of Janice Carr/CDC)
The strain, which was found in an ulcer on a diabetes patient, caused panic among the US doctors who found it.
More than 300 people who had come into contact with the elderly patient were tested to ensure it had not spread.
A report in the journal Science revealed that the bug had become dangerous because it had taken a gene from another bacterium in the ulcer.
There are many strains of bacteria which can resist modern antibiotics, with potentially lethal effects for the patients who catch them.
Staphylococcus aureus is carried by a high proportion of the population in their noses or on the skin, but can cause infections if they get into wounds.
While some strains are hard to treat because they resist certain antibiotics, doctors fear that even those used as a "last line of defence" will soon lose their potency.
There have been a number of reported cases of "vancomycin-resistant" Staphylococcus (VRSA) - signifying a strain which presents a high degree of resistance to conventional drugs.
The report in Science details a case in Detroit, which is unique because doctors were actually able to find the probable source of the mutation which turned a Staph infection with some antibiotic resistance into a "superbug".
The diabetic patient, from Detroit, had developed foot ulcers - a common complication of diabetes. These had become infected and were proving hard to treat with antibiotics.
Her doctor samples for analysis, which revealed that while most of the Staph bugs found were "only" resistant to some antibiotics, others could see off vancomycin as well.
This suggested that the change which produced the new bug may have actually happened on this patient, offering a golden opportunity to try to find out what had happened.
Experts at the Centers for Disease Control in Atlanta found traces of another bacterium, Enterococcus faecalis, which is common on hospitalised patients.
They found that the VRSA and this other bug shared some DNA - and a gene already known to help a bacterium fight vancomycin.
Further analysis revealed snippets of DNA - containing the gene, which were capable of "jumping" between different types of bacteria.
Fortunately, none of the 300 tests showed that the new bug had managed to spread.
Dr Donald Low, a clinical microbiologist at the University of Toronto, told Science: "We dodged another bullet."