At least 20 people have been killed during in an attempted breakout from a prison in northern Brazil.

Officials described the mass escape attempt at the Santa Izabel Penitentiary Complex, near the Amazon rainforest city of Belem in Para state, as a military style battle in which both prisoners inside and associates on the outside were armed.

"In the rescue attempt, explosives were used against one of the walls," the Para state security service said in a statement.

"The attempt was supported by an extremely heavily armed group. According to preliminary reports, the prisoners also had weapons inside the prison," it said.

Prison guards fought back in "an intense exchange of gunfire," it said.

The confirmed dead so far include 19 prisoners and outside attackers, and one guard.

Another four guards were injured, including one seriously, the security service said.

A headcount was being carried out in the prison to establish if anyone succeeding in escaping, while a police SWAT team had arrived to reinforce security. Police also recovered two rifles and five handguns at the scene.

Brazil is one of the world's most deadly countries, with around 60,000 homicides a year, and the prisons are notoriously overcrowded and violent.

There were 726,712 inmates as of June 2016 and capacity for only 368,000, according to the most recent official statistics.

Powerful drug gangs routinely take their turf wars from the streets of Rio de Janeiro and other big cities into prisons.

In the worst cases, security staff are reduced to bystanders as the criminal bosses run daily life.