Military police have entered a prison in north east Brazil, establishing tenuous control after a week of chaos and fighting between rival gangs that left 26 inmates dead.

The unrest was the latest in a spate of violence in the country's penitentiaries, in which at least 126 people have been killed since the beginning of the year. The fighting is typically between members of rival gangs that compete for control of drug trafficking routes outside prison walls.

A week after inmates first rioted at Alcacuz prison, riot police and other forces moved into the complex outside the city of Natal on Saturday. As a helicopter flew overhead, an armoured vehicle also entered the complex and later construction equipment was brought in.

Authorities would not say how many officers entered the complex, but an Associated Press reporter saw about 40 go in.

A few hours after the operation began, Eduardo Franco, a military police spokesman, said the complex was again under police control.

But Andre Azevedo, general commander of the Military Police in Rio Grande do Norte state, painted a bleak picture of the situation inside, saying that the entire system had broken down and maintaining control would be an ongoing battle. Many of the inmates are armed.

“Every time the police enter... they take away weapons that they find, but this is not enough to guarantee that tomorrow there won't be weapons,” he told reporters late Saturday. In the vast complex, prisoners can easily find or make weapons, he said.

Riot police during an uprising at Alcacuz prison (Reuters)

In the confrontation at Alcacuz, authorities said members of the Sao Paulo-based First Command, Brazil's largest criminal gang, known by the Portuguese acronym PCC, fought with local gang Crime Syndicate of Rio Grande do Norte.

Police forces have begun building a wall of shipping containers to separate rival prisoners from one another. Eventually, the temporary measure will be replaced with a concrete wall.

In the violence, many of the dead were dismembered, and investigators from the medical examiner's office on Saturday found several body parts, including a full skull, parts of two other skulls and other bones. Given the state of decomposition of the skulls, the office said they belonged to people killed in the violence a week ago.

Of the 26 bodies previously sent to the medical examiner, 22 have been identified, the office said in a statement.

Feminist protests demand end to violence against women in Brazil after gang rape of teenage girl Show all 10 1 /10 Feminist protests demand end to violence against women in Brazil after gang rape of teenage girl Feminist protests demand end to violence against women in Brazil after gang rape of teenage girl Brazilian women march in Sao Paulo during a protest following the gang rape of a 16-year-old girl Rex Features Feminist protests demand end to violence against women in Brazil after gang rape of teenage girl There have been calls for protests to end to what campaigners call Brazil's 'culture of rape' after the attack Rex Features Feminist protests demand end to violence against women in Brazil after gang rape of teenage girl An online campaign has been set up in response to the crime, using the hashtag #EstuproNuncaMais, meaning 'rape never again' Rex Features Feminist protests demand end to violence against women in Brazil after gang rape of teenage girl The 16-year-old victim was attacked in a poor neighbourhood in the west of the city on 21 May 2016 Rex Features Feminist protests demand end to violence against women in Brazil after gang rape of teenage girl Two of the attackers posted pictures and video on Twitter of the assault, which has shocked the country Rex Features Feminist protests demand end to violence against women in Brazil after gang rape of teenage girl Brazilian women protest in front of the Candelaria Church in Rio de Janeiro AFP/Getty Images Feminist protests demand end to violence against women in Brazil after gang rape of teenage girl Seven men have been charged in connection with the attack AFP/Getty Images Feminist protests demand end to violence against women in Brazil after gang rape of teenage girl Women's underwear and photos from Brazilian photographer Marcio Freitas displayed on Copacabana beach during a protest by non-governmental organization Rio de Paz (Rio of Peace) against rape and violence against women REUTERS Feminist protests demand end to violence against women in Brazil after gang rape of teenage girl Women's underwear smeared with paint is seen during a protest against rape and violence against women in Brasilia, Brazil REUTERS Feminist protests demand end to violence against women in Brazil after gang rape of teenage girl Demonstrators attend a protest against rape and violence against women in Brasilia, Brazil REUTERS

Much of the prison appears to have been damaged in the previous week. From a vantage point outside, holes could be seen in the walls and rooftops of buildings within the complex. Debris littered the ground. Even before the recent destruction, the prison was commonly called “Swiss cheese” because it was built on sand dunes, and prisoners over the years have managed to tunnel out.

G1 reported another riot Saturday in a prison in Pernambuco state, also in the northeast. It quoted officials as saying one prisoner was killed and 13 injured in the violence before authorities regained control.

The series of riots and grisly killings in Latin America's largest country has put a spotlight on overcrowding, underfunding and understaffing in the prison system.

Inmates next to riot policemen during an uprising at Alcacuz prison (REUTERS)

For instance, Alcacuz is home to more than 1,000 inmates, though it was built for 620. Images on TV and in newspapers of prisoners wielding weapons and cellphones have embarrassed President Michel Temer and put pressure on his administration to reform the system.

Authorities in Brazil are under pressure to crack down on crime, in general, and many states have struggled to do that in the context of shrinking budgets amid an economic recession.