Altering bacteria's immune systems could one day help prevent their resistance to antibiotics, a new study has found.

Researchers at Laval University in Quebec City and food company Danisco say they've discovered how bacteria take "pieces" of foreign DNA and embed them within their genome. When the bacteria come in contact with that foreign DNA down the road, they fight it off in an immune-style attack.

The scientists inserted plasmids — DNA molecules that bacteria routinely exchange — into the bacteria. These plasmids contained a gene for antibiotic resistance.

Once the plasmids were placed, the bacteria integrated parts of the DNA from the antibiotic resistance gene into their genome. This meant that when researchers tried to reinsert the plasmids, the bacteria fought them off.

"These bacteria had simply been immunized against acquiring the resistance gene," Sylvain Moineau, a professor at Laval's department of biochemistry, microbiology and bioinformatics, said in a release. "This phenomenon could explain, among other things, why some bacteria develop antibiotic resistance while others don't."

The finding could pave the way for the development of bacteria that are not immune to antibiotics. Antibiotic resistance develops when antibiotics fail to kill all bacteria, leaving some to grow into a new, resistant strain.

Bacteria that develop resistance to common antibiotics affect more than 250,000 Canadians a year, according to the Canadian Medical Association. About 8,000 people die from those infections.

The study also found that the immune response demonstrated by the bacteria also causes them to effectively fight off viruses known as bacteriophages. Future research could identify how food companies that sell food with bacterial cultures such as yogurt and cheese could prevent bacterial contamination.

The study is published in Thursday's issue of Nature.