MONTERREY, Mexico (Reuters) - A battle between the feared Zetas drug cartel and rivals at a prison left 49 people dead in the northeastern Mexican city of Monterrey, authorities said on Thursday, days ahead of a planned visit by Pope Francis to another jail in Mexico’s far north.

The incident was one of the worst in a series of deadly riots in recent years to rock the country’s overpopulated prisons, some of which are largely controlled by cartels.

Fighting broke out before midnight in two areas of the Topo Chico prison between supporters of a gang leader known as “Zeta 27” and another group, with prisoners using bottles and blades, Nuevo Leon state Governor Jaime Rodriguez said.

“Topo Chico is a ... very old prison. A prison with very difficult security conditions,” said Rodriguez, who described the state’s prison system as a “time bomb” that needed to be defused. Rodriguez himself survived two assassination attempts while opposing drug cartels as mayor of a suburb of Monterrey, Mexico’s third most populous metropolitan area and home to many of the country’s largest corporations.

A 2014 human rights report faulted Topo Chico for not preventing violent incidents. The prison has long housed members of the Zetas, known for extreme violence. One Zetas leader was stabbed to death there in September.

Authorities revised down their initial death toll from 52, out of a total of about 3,500 prisoners.

One victim died from gunfire, while the rest were killed from a combination of knives and other objects like bottles and chairs. Flames licked the night sky after inmates set light to food storage areas.

Slideshow ( 18 images )

Milenio TV reported that inmates’ relatives who had been within the prison’s premises for conjugal visits had seen inmates with burns. Twelve people were injured, five seriously, the state government said.

Speaking to local radio, Rodriguez acknowledged the public perception that the Zetas dominated the facility and said the prison system was one of his principal concerns.

“The problem is they have people like my brother living with narcos,” said an angry relative of an inmate doing time for robbery, waiting for names of the victims at the prison gates.

Rodriguez said 40 victims had been identified so far. The names of Zeta 27 and a rival known as El Credo were not among a list of 20 names released by state government.

Rodriguez said the fighting had been brought under control at about 1:30 a.m. (0730 GMT) on Thursday and ruled out a prison break, adding no women or children were hurt. Worried family members at one point forced open the prison gates and threw timber and stones at riot police inside, television images showed.

Authorities are transfering inmates out of the prison to bring down the population, with 60 people set to be moved on Thursday.

Slideshow ( 18 images )

Pope Francis is set to begin his first visit to Mexico as pontiff on Friday. Next week, he will visit a prison in border city Ciudad Juarez, once one of the world’s most violent cities.

Both Monterrey and Ciudad Juarez are more peaceful than at the peak of the war between rival cartels for control of routes to nearby Texas.

For much of the last decade, the Zetas spread terror across Mexico before being debilitated by arrests and deaths of their founding members.

Juan Pedro Saldivar Farias, or Zeta 27, has been mentioned in local media as a suspect in the 2010 murder of U.S. citizen David Hartley.

Thursday’s riot was a blow to Nuevo Leon, where many were uplifted when Rodriguez, a blunt, outspoken rancher with a penchant for cowboy hats known as “El Bronco,” or “the gruff one,” defeated President Enrique Pena Nieto´s ruling party last year, becoming Mexico’s first independent candidate to win a governorship.

In 2012, at least 44 inmates died in another Nuevo Leon prison when members of the Zetas plotted with prison guards to stage an elaborate escape.