Cincinnati Zoo in the US is facing a public backlash after shooting dead one of the gorillas in its care.

A young boy got into the gorilla enclosure and was confronted by a silverback male gorilla named Harambe. The gorilla repeatedly dragged the boy through the water. To save the boy, the zoo's staff shot and killed Harambe.

The story is particularly sad because Harambe was a western lowland gorilla (Gorilla gorilla gorilla), a subspecies of western gorilla that is critically endangered.

The public outrage has mainly focused on whether it was truly necessary to kill Harambe. The zoo has defended its actions, arguing that non-lethal methods such as tranquiliser darts are slow and would have put the child at more risk. Gorilla experts have, in the main, supported the zoo. The Cincinnati police have said they will investigate the child's parents' actions.

The biggest difficulty is figuring out how dangerous Harambe truly was. But decades of research into gorillas does offer some clues. The truth is that gorillas need very careful handling.

Gorillas were once depicted as violent brutes who would kill a human at any chance encounter. It is not a coincidence that the monstrous giant ape King Kong was portrayed as a gorilla.

In different circumstances, gorillas can be truly dangerous

However, from the 1970s onwards the primatologist Dian Fossey transformed gorillas' reputation with her pioneering studies of wild mountain gorillas. These are a different species to Harambe, but the differences are subtle.

Fossey found that the gorillas were hardly ever violent. For the most part they were peaceful.

David Attenborough was filmed with some of Fossey's gorillas for the 1979 television series Life on Earth. The encounter has gone down in television history, because some of the young gorillas started playing with Attenborough.

Clearly, it is possible to meet a gorilla and come away entirely unharmed. But the gorillas Attenborough met had been carefully habituated to humans over many years, and everyone involved knew how to treat them with respect.

In different circumstances, gorillas can be truly dangerous.

Most gorilla violence is directed towards other gorillas.

There have been cases where gorillas attacked and even killed humans, but such incidents are rare

They live in groups, in which one dominant male silverback controls several females and youngsters. If another male approaches, the silverback will try to drive him off. He begins by making threatening displays such as grunting, hooting and chest pounding. If that does not work, he may attack.

Many silverbacks have tell-tale scars from such encounters. The losers sometimes do not survive.

Gorilla attacks on humans follow a similar pattern: the gorilla has to be provoked first.

Ian Redmond of Ape Alliance worked with Fossey in Rwanda for three years in the 1970s, and still works with gorillas. He says there have been cases where gorillas attacked and even killed humans, but such incidents are rare – and the human was always to blame.

"All the incidences I know where people have been hurt by gorillas, or in some cases killed by gorillas, are in the wild where the gorilla feared an attack or was actually attacked," says Redmond.

A gorilla that thinks it is in danger will first make threats. If the human ignores the threat display, or surprises the gorilla or gets in its way, it may then escalate to thumping, scratching and biting, and eventually charging

If the poacher had been an inch closer to the gorilla, he would probably have been disembowelled

"The people I know who have had that experience have been bitten or had a couple of ribs cracked," says Redmond. "They lived to tell the tale, but they ignored the warning signs."

He recalls meeting a poacher with scars across his abdomen where a gorilla had swiped him. If the poacher had been an inch closer to the gorilla, he would probably have been disembowelled.

If this all sounds a bit anecdotal, there is a good reason: there is hardly any research into gorilla attacks. While there is a regularly-updated Shark Attack File documenting shark attacks dating back hundreds of years, there is nothing similar for gorillas.

In fact, a 2012 review of human-wildlife conflicts cites only three incidences of gorilla attacks before 2000.

There have been a handful of other incidents reported.

A study published in 2008 found that female western gorillas frequently acted aggressively towards humans, presumably because they were not used to their presence. The researchers were following the gorillas, and reported that they sometimes "grasped our legs with their hands".

A 2009 report into conflict between humans and apes documents how a silverback male attacked a man in the Kagwene Gorilla Sanctuary in Cameroon. The man was setting up traps, and the gorilla reportedly attacked him from behind as he was running away. The report cites other attacks in Bwindi, Uganda, but only when the gorillas were raiding crops outside their park boundaries.

Even when attacks do occur, they are rarely fatal

One of the main causes of human-gorilla conflict "is the expansion of human settlement into territory previously part of the gorilla habitat", according to a 2011 report that examined 20 years of mountain gorilla conservation. The report also says that "there is some uncertainty about whether habituation is a cause of this behavior".

A book chapter published in 2015 pulled together all the existing data and tried to figure out how aggressive apes really are. Its co-author Matthew McLennan of Oxford Brookes University in the UK stresses, once again, that gorilla attacks on people in the wild are very rare and usually motivated by a defensive instinct.

"Reports indicate that the target of gorilla aggression is usually an adult human, [for example] a hunter, not a child," says McLennan. Even when attacks do occur, they are rarely fatal.

These stories all relate to wild gorillas, but captive gorillas do not seem to be significantly different. There are only a few cases of captive gorillas behaving aggressively towards humans.

A 2014 study of human-animal relationships in zoos documented only a handful of cases of gorilla aggression. In one a gorilla had escaped its enclosure; in another a keeper was unexpectedly alone; and in a third instance "procedures were not correctly followed". None of these incidents led to deaths.

The gorillas banged the glass, charged at it and thumped their chest

However, there is evidence that an increase in visitor numbers could aggravate gorillas.

A study published in February 2016 followed three western lowland gorillas in Dublin Zoo, Ireland. It found that when visitor numbers went up the gorillas became more aggressive, both towards visitors and each other. The gorillas banged the glass, charged at it, and thumped their chests. They also bit, hit and threatened each other.

The authors recognise that "data on attacks are sparse" and therefore encourage zoos to record any incidents that take place. 

There are no known instances of a captive gorilla killing a human

This latest study echoes a 2008 study of UK zoos, which found that gorilla anxiety increased when visitor numbers went up.

In the wild they can roam freely. But in captivity they cannot escape their enclosure to take themselves out of a potentially stressful situation, such as the one Harambe faced. "Wherever they go they are in view," says Redmond. "That adds to their stress."

Nevertheless, to Redmond's knowledge there are no known instances of a captive gorilla killing a human.

Before the incident with Harambe, there were two cases of children getting into gorilla enclosures. Both were unharmed. However, in both cases the children were unconscious, so the gorillas would not have perceived them as a threat.

Most dramatically, in 1986 a gorilla in Jersey Zoo in the UK acted in a protective way after a boy fell into a gorilla enclosure.

All told, there have been three instances where children have fallen into gorilla enclosures, and in two cases nobody died. "This time somebody did, and it was the gorilla," says Redmond.

He says the most important thing is not to judge the actions of Cincinnati Zoo, but to learn from the incident to prevent anything like it happening again.

Melissa Hogenboom is BBC Earth's feature writer. She is @melissasuzanneh on Twitter.

Join over five million BBC Earth fans by liking us on Facebook, or follow us on Twitter and Instagram.

If you liked this story, sign up for the weekly features newsletter called "If You Only Read 6 Things This Week". A handpicked selection of stories from BBC Future, Earth, Culture, Capital, Travel and Autos, delivered to your inbox every Friday.