Mexican authorities on Thursday pored through surveillance video showing a gunfight inside a prison in Ciudad Juárez, where 17 people were killed in a battle between rival gangs.
Three inmates entered cellblocks where there were 13 other prisoners on Monday, and a fight began. Sixteen men and one woman were killed in the ensuing violence, according to Juárez's mayor's office.
"This was a settling of scores inside the penitentiary," a spokesman for the public prosecutor's office in the state of Chihuahua, Carlos Gonzalez, told Milenio television.
Prison officials haven't confirmed how the inmates obtained pistols and assault rifles or which group started the melee. Video footage showed hooded, armed men restraining a guard, who then is pushed out of the way. The armed men open the door and fire inside the cell, as seen in the video.
Riot police eventually surrounded the building and regained control of the detention facility. But it was too late.
The city on the border with Texas has been racked by a brutal turf war between the local Juárez cartel, and the powerful Sinaloa cartel, headed by Mexico's most wanted drug boss, Joaquin "Shorty" Guzman.
Drug battles often continue behind bars.
More than 40,000 people have died in drug-related killing since Mexican President Felipe Calderon sent in the army to crush the cartels shortly after taking office in late 2006. Roughly a quarter of the deaths have been in Ciudad Juarez.
Despite the violence, the city's mayor, Hector Murguia, said the federal police would start being withdrawn from Ciudad Juárez in September. Federal police have been in charge of security in the city since early 2010.
In the prison violence on Monday, municipal police chief Julian Leyzaola said federal police officers opened fire on his vehicle when he arrived.
"I suddenly heard bursts of fire toward my vehicle," Leyzaola told reporters. "There was a group of 10 to 15 of them and they were all shooting at me."
The state's ministry of public security, which is in charge of federal police, did not immediately respond for comment.
Security has been a serious problem in prisons in Mexico, which are prone to outbreaks of violence and escapes.
Earlier this month, 59 inmates broke out of prison and a further seven were killed in Nuevo Laredo, a northeastern city also near the Texas border.
Reuters contributed to this report.