The benefits of protective bacteria - which safeguard organisms from further disease without causing harm - depend on how subsequent infections enter the body, a study of fruit flies has shown.
Scientists made their discovery studying the bacteria Wolbachia, which in itself does not cause disease but benefits its thousands of host species in many ways, including protecting from other infections.
They found that insects which carried Wolbachia and then contracted another infection through feeding - as they would in the wild - fought disease better than those which had the same infection injected into their bodies.
Researchers say that studies which focus on natural routes of infection could improve our understanding of immunity in many species.
Their study also resolves a long-term puzzle for scientists. It confirms that Wolbachia - which is known to provide protection from bacterial infections in other insect species - offers the same benefit in flies.
The team observed this finding in flies that had been infected orally, but not in those infected via an injection.
Researchers from the University of Edinburgh studied bacterial infection in fruit flies, some of which were carrying Wolbachia bacteria.
When infected with another bacterial infection - either orally or by injection - flies carrying Wolbachia which had been infected orally were best able to fight the disease. Further analysis showed these flies' immune systems had triggered production of antimicrobial and detoxifying molecules in response to the infection.
Researchers also found that male flies experienced greater disease protection with Wolbachia than females, and suggest a greater focus on differences in immune response to infection between the sexes. Their study, published in Proceedings of the Royal Society B, was supported by the Wellcome Trust and by Society in Science (ETH Zurich).
Dr Pedro Vale, of the University of Edinburgh's School of Biological Sciences, who led the study, said: "Most experimental studies employ artificial routes of infection, and we may be missing out on important aspects of biology. Understanding more about the impact of contracting infection through natural routes could add to our body of knowledge about immune responses and disease."