RIO DE JANEIRO/SAO PAULO (Reuters) - Hundreds of inmates from rival drug gangs clashed on Thursday in a Brazilian prison where 26 inmates were killed in the latest of a string of bloody uprisings, television images showed.

Inmates are seen during an uprising at Alcacuz prison in Natal, Rio Grande do Norte state, Brazil, January 19, 2017. REUTERS/Josemar Goncalves

Police fired rubber bullets and tear gas canisters into the yard of the Alcacuz prison in northeastern Brazil as helicopters buzzed overhead. Prisoners erected makeshift barricades, traded blows with wooden clubs and hurled stones from rooftops.

Some police appeared to be firing live rounds from a watchtower. There was no immediate report on deaths, but several inmates could be seen limping and tending to fallen comrades.

The outbreaks of violence were the latest in Brazil’s beleaguered penitentiary system, where about 140 people have died in clashes in recent weeks.

The overcrowded prisons are now the battleground in a quickly escalating war between the nation’s two biggest drug gangs, the Sao Paulo-based First Capital Command (PCC) and the Red Command based in Rio de Janeiro.

For two decades, the two factions have maintained a working relationship, ensuring a steady flow of drugs and arms over Brazil’s porous border. But about six months ago, the PCC began trying to muscle the Red Command out of key drug routes.

The PCC has aggressively moved into new areas in the north and northeast of Brazil, where the deadly prison riots have taken place in recent weeks. In response, the Red Command allied itself with local gangs, enlisting them to take on the PCC.

The bloodshed has mostly played out among inmates allied with the rival gangs, but security experts fear it will soon spill into Brazil’s already violent city streets.

Late Wednesday, 13 buses were burned in Natal, the state capital about 25 km (15 miles) south of the Alcacuz prison. A police precinct and a government car in the city were also hit with gunfire. Nobody was injured in the incidents, which authorities said were carried out by the local drug gang confronting the PCC.

Slideshow ( 8 images )

President Michel Temer authorized the army on Thursday to patrol the streets in Natal and other cities in the state of Rio Grande do Norte, said officials at the presidential palace.

The violence, the deadliest outbreak in over two decades in the harshly criticized penal system, has gripped Brazil.

Cellphone videos of the clashes were circulating widely on social media, some showing gang members chopping the heads off their rivals, slicing their hearts out and disemboweling them.

A SWAT team entered the Alcacuz prison on Wednesday night to transfer over 200 prisoners belonging to the “Crime Union of RN” - a gang carrying the state’s initials - whose members were killed this weekend by PCC inmates.

Police said they searched cells and confiscated several guns, knives, homemade weapons and bullet-resistant vests.

Caio Bezerra, the top security official for Rio Grande do Norte, told reporters the operation on Wednesday was successful and prisoners did not resist.

Major Eduardo Franco, a spokesman for state police, told Reuters late on Wednesday the prison was back under control.

The recent spate of killings began on Jan. 1, when the powerful North Family gang, an ally of the Red Command, killed 56 inmates at a prison in Amazonas state, mostly PCC members.

The North Family controls a lucrative cocaine route along the Solimoes, a branch of the Amazon that flows from Colombia and Peru, the world’s top two cocaine-producing nations.

The PCC retaliated on Jan. 6 by killing 33 inmates at the Monte Cristo prison in the neighboring state of Roraima and then carrying out the killings at Alcacuz this weekend.

At least one inmate was also killed in another prison in Rio Grande do Norte when members of different gangs clashed.

Prisoners fought, burnt mattresses and ripped down part of the roof in a block of the Caico prison before guards took control of the situation, said a spokesperson for the state’s security secretariat. Five inmates were injured in the clashes.