Mexican authorities on Tuesday secured the release of 13 security personnel who had been taken captive the previous day by protesters allegedly infiltrated by a criminal group, a senior official said.

Several thousand demonstrators had overrun the city of Chilpancingo in the crime-plagued southern state of Guerrero on Monday, demanding the release of two suspected members of a drug gang, according to the government.

After negotiations with the authorities, the protesters also agreed to stop blocking the highway to the nearby resort city of Acapulco, Guerrero state governor Evelyn Salgado said on Twitter.

"Without repression or confrontation, we achieved the release of 13 detained public servants, who are already being provided with medical attention to ensure their good physical condition," Salgado said.

The protesters also returned an armored police vehicle that they had used to smash open an entrance to the governor's palace in Chilpancingo.

Salgado did not say if any concessions had been made to secure the release of the 13 captives, who included five members of the National Guard, five police officers and three officials, including a federal agent.

According to President Andres Manuel Lopez Obrador, the protesters had demanded the release of two members of the Los Ardillos drug trafficking group who were arrested last week.

"We won't be hostages to anyone," he told reporters.

Security Minister Rosa Icela Rodriguez said that the government had chosen the path of "dialogue" with the demonstrators.

Guerrero, one of Mexico's poorest states, has endured years of violence linked to turf wars between drug cartels.

Chilpancingo was shaken over the weekend by the murder of five taxi drivers.

Violence in the city escalated after a video leaked on July 5 showed the city's mayor, Norma Otilia Hernandez, who is affiliated with Lopez Obrador's party, meeting with a Los Ardillos gang leader.

Lopez Obrador ordered an investigation into the meeting, which Hernandez described as a chance encounter.

The president has struggled to curb the brutal violence plaguing Mexico since taking office in 2018.

The leftwing populist championed a "hugs not bullets" strategy to tackle violent crime at its roots by fighting poverty and inequality with social programs, rather than with the army.

His critics argue that the approach has left swathes of the country under the control of organized crime.

"Evil cannot be confronted with evil," Lopez Obrador said on Tuesday, arguing that the cartels flourished in states like Guerrero because previous governments had allowed them to build support by giving out gifts.

Mexico has registered more than 350,000 murders and some 110,000 disappearances -- most attributed to criminal groups -- since the launch of a controversial military anti-drug offensive in 2006.

Last month, 16 police employees were kidnapped by gunmen demanding the dismissal of three state security officials in the southern state of Chiapas.

They were freed after several days of captivity.