Mountain gorilla groups are friendly to familiar neighbours - provided they stay out of "core" parts of their territory - new research shows.
Gorillas live in tight-knit groups, foraging, resting and sleeping together around a "core home range" and a wider "peripheral" range.
These groups sometimes split permanently, separating gorillas that may have lived together for years and may be closely related.
The new study - by the Dian Fossey Gorilla Fund (Fossey Fund) and the University of Exeter - shows groups that were previously united are more than four times as likely to be friendly to each other when they meet, even if they had split over a decade earlier.
Gorillas tend to react aggressively when another group strays into their core territory - regardless of whether the intruders are familiar. But in the peripheries of their home range, this heightened aggression only applies to less familiar groups, with groups that were previously united more tolerant of each other.
"Meetings of groups are fairly rare, and at first both groups are usually cautious," said Dr Robin Morrison, of the Fossey Fund and Exeter's Centre for Research in Animal Behaviour.
"They often beat their chests and show off their strength, but the interaction can then either become aggressive - with fighting and screaming - or 'affiliative'.
"In affiliative interactions, the initial tension passes and the groups intermingle. They may rest together, and younger gorillas will often play with youngsters from the other group."
Humans have an unrivalled capacity for cooperation based on the friendships that extend beyond our immediate group, and one theory for the evolutionary benefit of these wider friendships is that they allow shared access to space and resources with a reduced risk of aggression.
The new study is the first to test this theory beyond humans - and the findings suggest gorillas may indeed benefit in this way from maintaining "friendships" between groups.
"The pattern we found mirrors what we see in humans," Dr Morrison said.
"We also have concepts of public spaces outside our 'range' where we tolerate anyone, spaces like our homes where we tolerate certain individuals, and private spaces within those homes reserved for close family or just ourselves."
Understanding these patterns is also important for conservation.
"Mountain gorillas have less than 800 km2 of habitat remaining," said Jean Paul Hirwa, Gorilla Program Manager at the Fossey Fund and co-author on the study.
"As a result of extreme conservation efforts, the population has been growing over the last 30 years while their habitat has not."
"Understanding how groups interact and share their limited space is important for estimating future population dynamics and trends in this endangered species."
The study used 16 years of data on the movement and interaction patterns of 17 mountain gorilla groups in Volcanoes National Park, Rwanda.
The paper, published in the Journal of Animal Ecology, is entitled: "Inter-group relationships influence territorial defence in mountain gorillas."