A grisly method by which bacteria dispatch their distant relatives also creates conditions in which the attackers can thrive, research has found.
Families of bacteria cells are known to kill adjacent, unrelated cells by injecting them with toxins - now researchers have found that cells which compete in this way are able to flourish.
Their approach creates surviving pockets of closely related bacteria with a common interest in ensuring their collective genes are passed on to future generations.
The bugs live alongside one another, cooperating to share tasks and resources such as nutrients.
Unrelated microbes, which might cheat by taking resources without contributing, are excluded from the group.
Scientists carried out experiments and created mathematical models of cholera bacteria to better understand how microbes organise themselves in their typically packed populations.
They found that the stabbing tactic - which has no effect on genetically similar relatives - helps create clusters of bacteria that cooperate with each other.
Researchers say the mathematical patterns that form as populations of bacteria cells undergo change are also seen in inanimate objects in nature, such as in magnetic particles. The science of these patterns is well known, and so gives valuable information on how bacteria might behave.
The study, supported by The Wellcome Trust, The Human Frontier Science Program, The National Science Foundation, NASA and The Gordon and Betty Moore Foundation, was published in Nature Communications.
Dr Luke McNally of the University of Edinburgh's School of Biological Sciences, who led the study, said: "Our work shows that bacteria engage in a type of tribalism, and try to kill competitors to protect a peaceful territory. They will fight against others to whom they are not closely related, and the minority population will die, creating pockets of families which live harmoniously."