Updated

An hours-long rolling gunbattle at a northern Mexico prison left seven dead and 13 injured before control was re-established Wednesday morning, authorities said.

Continuous automatic gunfire was heard late Tuesday at the prison in Ciudad Victoria, the capital of the border state of Tamaulipas.

The gunfire continued into the morning at the prison, which has been one of Mexico's most troubled. Authorities reported the facility was back under control in late morning.

The state security spokesman's office said three police officers and four inmates died in the shootouts, while six police and seven prisoners were wounded.

Inmates at the state prison somehow managed to obtain guns and began fighting authorities.

Mexico's National Human Rights Commission said Wednesday that it had sent a delegation to the lockup to document the incident and check the health of inmates.

In a statement, the commission said it audited the prison in 2016 and found a long list of problems, including overcrowding, insufficient supervision and personnel, inadequate health services and conditions of self-government by inmates.

The prison has been the scene of shootings, smuggled guns, riots and escapes. Ciudad Victoria has long been dominated by the hyper-violent Zetas drug cartel.

A fight between prisoners at the same facility left three inmates dead in March. That clash followed a riot and mass escape through a tunnel that inmates built in a prison patio. Most of the prisoners have since been recaptured.

Inmates have frequently had access to guns in the prison.

During the March escape, at least one prisoner had a gun that he used to kill a passing motorist in a carjacking.

Police later found two assault rifles buried in a planter in the prison.