The riot killed 49 people inside Topo Chico prison in Monterrey, a spokesman for the state's governor told reporters Thursday afternoon. Authorities initially announced a higher death toll, but later corrected that figure.
Twelve others were injured, including five who are in critical condition, he said.
Video showed flames rising from the prison -- the result, Nuevo Leon state Gov. Jaime Rodriguez said, of inmates setting fires in two areas inside.
The violent clashes come just one day before Pope Francis arrives in Mexico, a trip that will include a stop at a prison in Ciudad Juarez, a city on the mend after once being known as the murder capital of the world.
Relatives demand answers
The riot started half an hour before midnight Wednesday and was under control by 1:30 a.m. (2:30 a.m. ET) Thursday, Rodriguez said.
A newer group of inmates attacked "a group that already had control of the prison for a long time," Nuevo Leon Attorney General Roberto Flores said Thursday night in a video statement posted on the state's official Facebook page
"We have taken total and complete control of the prison," Flores said. "We are going to take the necessary action so that calm returns to this overcrowded place and these kinds of situations do not happen again."
State and federal forces as well as relatives of inmates amassed outside the site. Frantic family members tearfully told CNN affiliate FOROtv that they were worried about loved ones inside.
Images from the CNN affiliate showed people pushing on gates outside the prison. Another group shoved at a line of police officers standing guard near the facility.
"I don't know if my son is dead!" a woman screamed. "Please, help us. The director should come out and face us, and give us the names. "
"We don't really know what's happening," another woman told reporters. She said her son managed to call her from inside the prison, recounting how once the riot started, he hid for safety in the women's wing.
Another woman told reporters a similar story -- of her son seeking shelter in the women's wing.
"There is a riot. They want to kill us all. Come ask for me," the woman said her son told her.
State officials released a list of 40 victims who died in riot, and said investigators were still working to identify others.
By Thursday night, family members had left the area surrounding the prison after authorities ended visiting hours with inmates inside. Federal police and Mexican military troops surrounded the facility.
The governor called the riot "unfortunate and painful."
Past riots sprang from cartel rivalries
Overcrowding is a major problem in Mexican prisons, which have seen deadly riots and violence in the past.
At the same prison in Monterrey, three inmates were stabbed to death in February 2012.
That same month, 44 inmates were killed and 30 escaped
in a riot at a prison in Apodaca, near Monterrey. Security officials blamed the violence on a fierce rivalry between drug cartels inside that prison.
In 2011, the head of security at the Topo Chico prison was found dead and mutilated. Authorities said that a note, presumably from a drug cartel, was left with the body.
"It seems like we haven't learned our lesson," said Martin Carlos Sanchez, who directs a prison reform and monitoring program.
For years, advocates had warned that the situation at the Topo Chico prison was out of control, Sanchez told CNN en Español's "Conclusiones."
"We think there should be stronger, more robust strategies, so we don't reach this point, which is truly total abandonment," he said. "These violent acts speak of the urgent need to do something in prisons."