RIO DE JANEIRO — A month before Rio de Janeiro hosts South America’s first Olympic Games, two cellphone videos have brought home the grim reality of rising violence in the city's teeming favelas — the poor communities that are home to almost a quarter of its population.

In one clip, small children cower in fear in a cable-car gondola while a gun battle rages below — at 4 o'clock on a Monday afternoon. The clip hit the Internet on the same day that Mayor Eduardo Paes told CNN that the state government is doing a “terrible” job with security. By Monday night, the video was on the front page of Brazil’s biggest news site, the Globo network’s G1.

That morning, police and firefighters organized a protest at Rio’s international airport over violence and unpaid salaries. “Welcome to hell,” a banner read. “Police and firefighters don’t get paid, whoever comes to Rio de Janeiro will not be safe.” It was their second demonstration at the airport, which will receive Olympic participants and visitors.

Rio's rising violence and falling economy

The second video, released Friday, shows a baying crowd following police officers who are hurriedly carrying a 16-year-old boy they had just shot and bundling his body into the back seat of their car in the Borel favela. He died en route to a hospital.

The violence is deepening anguish and anger among residents, and it comes at a time when Rio’s state government is broke and has slashed police budgets by a third.

It was a calm Monday afternoon when a young mother set out with her 3-year-old daughter and 2-month-old son, along with two friends and one of their sisters, just 10, for a spin around the Complexo do Alemao favela, not far from Rio’s international airport. But when they were leaving the Palmeiras station, one of six served by a cable-car network, a gun battle broke out below them between police and a drug gang.

“It was the most horrible thing. It was desperation. The children were crying, and we were trying to protect them. There is a big risk of a bullet hitting,” the woman said. She spoke on the condition of anonymity because of fear of reprisals — from the gang or police.

The complex of favelas was pacified by police and military after a battle in 2010, a high-stakes operation carried live on TV. The "pacification" policy was initiated in 2008 to bring peace to communities dominated for decades by violent drug gangs, and armed police bases have since been installed in 38 of Rio’s favelas. The cable car was later opened and became a tourist attraction for a time.

But peace has been hard to come by, said the young mother, who filmed the video and was surprised when it went viral.

“It is very difficult. We don’t live with it. We survive it. Out of nothing, there is a gunfight, and there are residents in the street, children coming out of school,” she said. The pacification policy, she added, has failed. “Before the police base, the community never had these gunfights,” she said. “For me, it was a big mistake.”

A police spokesman said by email that officers were told that armed gang members had been seen in the area and that officers were fired upon when they went to investigate. Three other confrontations were registered Monday evening. No injuries were reported, police said.

The second video was recorded after Jhonata Alves, 16, was fatally shot in the Borel favela Thursday. According to local media reports, he was carrying a bag of popcorn when police opened fire and killed him.

"There was no gun fight. They shot my son in the head, ended my life. Everybody saw him with a packet of popcorn in his hand," his mother, Janaína Alves, said, according to the O Globo newspaper.

Rio tabloid O Dia published this video of police carrying the dying boy to their car while residents follow, shouting and screaming. The video was supplied anonymously via WhatsApp, an O Dia reporter said.

“Cowards!” one man can be heard roaring. “They killed the boy, what is this?” a woman exclaims in horror.

The police spokesman said that officers had stopped two men on a motorcycle and that one of them opened fire, as did other men in a nearby alley. He said police opened fire in response. Residents blocked streets and threw rocks at the officers.

Jhonata’s grandfather, Antonio Alves, told The Washington Post that the family would not comment on the tragedy, as a lawyer was handling the case. Across Rio state, killings by police rose 91 percent in May compared with a year ago, with 84 people killed.