Image copyright AP Image caption Firefighters recovered four bodies from the wreckage of the aircraft

Four police officers have died after their helicopter crashed over Rio de Janeiro's notorious City of God favela.

In video footage of the crash, sustained gunfire can be heard before the helicopter drops from the sky, narrowly missing a main road.

The helicopter was giving support to a police operation against gangs in the favela, according to police.

Police reportedly began a large scale operation on Sunday in western Rio, with arrests and seizures of drugs.

'Fell in a ditch'

There had been several clashes during Saturday between police and criminal gangs operating in the City of God favela area.

Firefighters removed the bodies of the victims from the wreckage, which could be seen in the footage crumpled and smoking.

A police spokesman said that forensics officers were examining the wreckage to determine the cause of the crash.

Image copyright Reuters Image caption Police had been carrying out anti-drugs operations on Saturday in the City of God favela

One man who saw the incident, Thiago Duarte, told Associated Press: "We were here watching the shooting in the woods... Suddenly a friend shouted 'the bullets reached the helicopter, it's going to come down!'

"It was clear that [the pilot] was trying to do everything to avoid falling over the shanty town or on the expressway, so it turned back and fell into the ditch."

On Sunday, police backed by an armoured vehicle carried out further operations, with at least two people arrested, another injured and a number of drugs seized.

Rio state security secretary Roberto Sa said police were investigating a territorial dispute between members of two favelas in western Rio.

If the helicopter was shot down by gang members, it would not be a first for the city, which hosted the 2016 Olympics.

In 2009, drug traffickers opened fire on a police helicopter, causing it to explode and crash land on a football pitch, killing both pilots.

Violence has been on the rise in Rio over the past two years following the failure of a 2010 programme to rid the favelas of drug gangs.

A total of 3,649 murders were reported in 2016 up until the end of September, a rise of almost 18% on the same period last year.</s>RIO DE JANEIRO A police helicopter in Rio de Janeiro crashed Saturday evening, killing four officers after a day of intense firefights between law enforcement and suspected criminals in the slum known as City of God.

It was not clear whether the helicopter had been hit by gunfire or whether another factor caused it to go down. In a statement, the police said they were investigating.

Amateur video sent to local television stations showed the aircraft spinning as it appeared to plummet straight down. The helicopter fell in a populated area near City of God, but crashed in an open space near a major highway.

Firefighters extricated the victims' bodies from the wreckage Saturday evening.

Crime and violence have rebounded across Rio, just months after Brazil's second-biggest city hosted the 2016 Olympics.

An economic recession, rising unemployment and overstretched public finances have emboldened criminal groups in areas like City of God, one of the best known of the city's so-called favelas, sprawling slums that stretch across vast suburbs and climb up the scenic hillsides of central Rio.

In recent years, police had successfully pushed out drug traffickers and other gangs from many favelas.

Still, crime is now worsening just as the state government, responsible for most security across a region of more than 16 million people, faces an expected budget shortfall of about 20 billion reais ($5.91 billion).

The murder rate across Rio through September climbed almost 18 percent from the same period a year earlier, to 3,649 reported deaths, according to state statistics. Street crimes, including heists on public transport, surged by 44 percent, to nearly 92,000 reported incidents.

Though crime in Rio remains far lower than its peak in the 1980s and '90s, recent firefights and the crash on Saturday recalled periods in which the city erupted in conflict.

In 2009, drug traffickers shot down a helicopter, killing two crew members, as police were seeking to "pacify" favelas ahead of the Olympics and 2014 World Cup, also played partially in Rio.

The 2009 incident, the first downing of an aircraft by criminals in Rio, underscored the challenge for law enforcement in a city where heavily armed gangs increasingly possess enough firepower to contend with state security forces.

(Reporting by Paulo Prada; Editing by David Gregorio)</s>Footage from social media shows a police helicopter getting into difficulty after being shot at while flying over a Rio de Janeiro slum known as City of God. The helicopter crashed, killing four officers on board, although it is not yet clear whether the gunfire was the direct cause of the crash
Four policemen are killed in Brazil after their helicopter is shot down by a "gang".