RIO DE JANEIRO/SAO PAULO (Reuters) - Police put down a new uprising at a prison in northeastern Brazil where 26 inmates were killed by a rival gang faction over the weekend and questioned five drug gang leaders they think ordered the bloodshed, authorities said on Monday.

An inmate talks with riot-police after a new uprising broke out at Alcacuz prison in Natal, Rio Grande do Norte state, Brazil, January 16, 2017. REUTERS/Josemar Goncalves

A SWAT team entered the prison before midday “to get control of the situation,” said Major Eduardo Franco, spokesman for police in the state of Rio Grande do Norte, where the prison is located.

Yet for most of the afternoon, television images showed inmates on the roofs of at least two wings of the Alcaçuz prison, wielding large knives, waving banners with gang acronyms and yelling death threats to rivals.

By evening, police said the SWAT team gained control of the wing housing members of Brazil’s most powerful drug gang, who until nightfall had refused to hand over their weapons and allow police to enter their area.

The officers located and questioned five of the prisoners who they think led the weekend killing spree of members of a rival drug gang. The five will be transferred to other prisons, the locations of which were not disclosed.

It was in the same prison, located about 25 km (15.5 miles) south of the state capital Natal, that members of the powerful drug gang the First Capital Command (PCC) slaughtered 26 other inmates from a rival gang in a riot that began late Saturday and was not halted until Sunday.

As in a series of other prison uprisings in recent weeks, many of those killed had their heads cut off and were badly mutilated or burned.

At least 140 inmates have died in Brazil’s prisons in just over two weeks.

The intense violence is the result of a split between the PCC and Brazil’s second-most powerful gang, the Red Command.

Slideshow ( 3 images )

For more than two decades the two gangs maintained an uneasy working relationship, ensuring that a steady flow of drugs and arms easily made its way over Brazil’s porous borders with the world’s biggest cocaine-producing nations.

But about six months ago, security officials and experts say, the PCC moved to fully take over trafficking routes and tried to push the Red Command aside.

The Red Command responded by forming alliances with smaller regional gangs, primarily in Brazil’s Amazon region and in the northeast, in an attempt to block the PCC from taking over those drug routes and gaining new turf.

A New Year’s Day prison massacre at the Anisio Jobim prison complex in Amazonas state in which 56 died ignited the recent violence.

Most of those killed were members of the PCC, butchered by members of the North Family gang, which is allied with the Red Command.

It was Brazil’s deadliest prison uprising since a 1992 rebellion at the Carandiru penitentiary in Sao Paulo state that saw police storm the building and kill 111 prisoners.

After the Jan. 1 bloodletting, members of the PCC on Jan. 6 murdered 33 inmates at the Monte Cristo prison in the Amazonian state of Roraima.

Videos taken by inmates showed the slaughter, with those hacking away at bodies saying they were doing so in revenge for their “brothers” killed the week before.

Brazil’s prisons, mostly under control of states and not the federal government, have for decades been in a state of chaos, with extreme overcrowding and escapes and violence the norm.

The prisons are also largely run by prison gangs and the state, experts and authorities acknowledge, has little control over the institutions. Drugs, guns and all manner of contraband seemingly enter the jails at will.