Updated

A riot and fire broke out Thursday at a prison in northern Mexico, killing at least 52 inmates just days ahead of a planned visit by Pope Francis to another prison in the country.

Nuevo Leon State Gov. Jaime Rodriguez said the riot was caused by two rival factions inside the Topo Chico prison in Monterrey. He said one of the factions was led by a member of the infamous Zetas drug cartel, and 12 inmates were left injured.

Rescue workers could be seen bringing injured inmates away from the prison, at least some with burns.

Images broadcast by Milenio TV showed flames leaping from the prison, with a crowd of people bundled against the cold gathered outside the prison. Some shook and kicked at the prison gates, demanding to be allowed in.

The fire appeared to have been extinguished soon after sunrise.

"I want to know that my daughter is OK. She is in the infirmary. There are children in there," one woman said outside the prison said, according to Reuters. Milenio TV reported that inmates' relatives had been inside the facility for conjugal visits.

Images broadcast on television showed police vehicles patrolling the streets near the prison.

Witnesses said the fire broke out just after midnight amid shouts and sounds of explosions. A thick cloud of smoke rose, apparently from inmates burning mattresses.

Pope Francis will begin his first trip to Mexico as pontiff on Friday and will visit a prison in the border city of Ciudad Juarez next week.

Mexico's official National Human Rights Commission reported in 2013 that the country's prison system is plagued by violence and cases of inmate control, symptoms of corruption and lack of resources.

The report, based on visits and interviews at 101 of Mexico's most populated prisons, found that 65 of the facilities were run by inmates, not authorities.

In one of the worst incidents in 25 years, 44 inmates died in a prison massacre in February 2012 in Apodaca, Nuevo Leon. After the incident, three top prison officials and 26 guards were accused of helping inmates escape in the confusion.

In 2013, 13 people were killed and 65 were injured in a prison riot in the central Mexican state of San Luis Potosi, which was blamed on gang violence, Reuters reports.

The Associated Press contributed to this report.