A fight at a prison in northern Mexico has left at least 16 inmates dead and five wounded, the local authorities said, in one of the worst outbreaks of violence in the country’s troubled penal system for years.

The violence broke out Tuesday afternoon at the Cieneguillas men’s penitentiary in the state of Zacatecas, said the state’s public safety secretary, Ismael Camberos Hernández. He said that prison officials were alerted by alarms and the sounds of gunshots and that they grappled for nearly three hours to bring the situation under control.

Four guns were discovered in the prison after the riot, Mr. Hernández said. He said they had most likely reached inmates on Tuesday, when relatives could visit for the last day of the year. Prison personnel also confiscated cellphones and knives during an inspection of inmates’ cells on Sunday, Mr. Hernández added.