The findings, published in Nature Genetics, show how quickly these life-threatening pathogens can disguise themselves with borrowed genetic decoys, and how hard it is for medicine to keep up.
Diseases caused by Streptococcus pneumoniae are thought to kill over a million young children around the world each year.
Vaccines that protect against these so-called pneumoccoccal infections are designed to recognize a material on the outer surface of a bacterium's cell called polysaccharide.
Each of over 90 kinds, or "serotypes," of these bacteria have a different polysaccharide coating.
In 2000, a vaccine that targeted seven serotypes proved highly effective when introduced in the United States. The same formula -- which also prevented transmission from children to adults -- was adopted in Britain.
Over time, however, the vaccine worked less well, so researchers led by Rory Bowden at the University of Oxford set out to discover why.
Combining cutting-edge genetic analysis with epidemiology, which examines how disease spreads, they found that the deadly pathogens escaped detection by swapping genes with other, slightly different, bacteria.
Remarkably, the exchanged genetic material came from precisely that part of the genome responsible for making the cell's coating, the area targeted by the vaccine.
The bacteria, in other words, had kept their virulence intact but changed their outward appearance.
"Imagine that each strain of the pneumoccoccus bacteria is a class of schoolchildren all wearing the school uniform," explained Bowden.
"If a boy steals from the corner shop, a policeman -- the vaccine -- can easily identify which school he belongs to by his uniform."
But if the boy swaps his sweater with a friend from another school, Bowden continued, the policeman will no longer know where to look and the thief, like the bacteria, will escape.
The researchers identified several such "recombined" serotypes resistant to the vaccine, and one in particular that had spread across the United States from east to west over several years.
They also observed -- for the first time outside a laboratory -- that the bugs were able to swap several parts of their respective genomes at once.
"This is of particular concern, as recombination involving multiple fragments of DNA allows rapid and simultaneous exchange of key regions of the genome within the bug, potentially allowing it to quickly develop antibiotic resistance," the researchers said.
In both the United States and Britain, the original vaccine has now been replaced with a new one that targets 13 rather than seven of the telltale serotypes.
But the scientists caution that the bacteria will continue to morph into new forms.