US defence chief Jim Mattis hears shots during visit to Rio de Janeiro

 Mattis reviews the honour guard on his arrival in Brasilia,  on Aug 13, 2018.
Mattis reviews the honour guard on his arrival in Brasilia, on Aug 13, 2018.PHOTO: AFP

RIO DE JANEIRO (AFP) - US Defence Secretary Jim Mattis got an alarmingly direct insight into Rio de Janeiro's violent crime wave when gunfire burst out close to his hotel during an official visit to the Brazilian city.

Mattis, at the start of a South American tour, said on Tuesday (Aug 14) that the sound of shots overnight had been upsetting.

"You remember every time you hear one of those shots somebody's life could be changing," he told reporters aboard his aeroplane.

"So I didn't make light of it. I was sad to hear it frankly."

Mattis was staying near Copacabana beach, an area where wealthy residents live a stone's throw from an impoverished favela called Chapeu Mangueira.

Rio's many favelas are almost daily witnesses to shootings, either between rival drug gangs or police and drug gangs.

Stray bullets are a constant menace to favela residents and also to people living in the surrounding streets.

Mattis acknowledged that parts of the United States also suffer serious gun violence.

"We have some cities in America that we know are tragically having this problem as well. This is what happens if we don't keep, I would call it consensual policing where the whole community helps police and is able to keep lawless elements at arm's length," he said.