Police in the northern Mexican state of Coahuila are searching for dozens of gunmen who attacked the city hall in the town of Villa Unión on Saturday.
More than 500 shots were fired in the gun battle which ensued between the suspected members of a local cartel and the security forces.
Twenty-one people, including four police officers, were killed.
President Andrés Manuel López Obrador said on Sunday that reducing crime remained his biggest challenge.
More than 60 armed men drove into the small town of Villa Unión around midday local time (18:00 GMT) on Saturday and started firing at the town hall which also is the headquarters of Villa Unión's small police force.
Residents recorded the arrival of the gunmen in the town.
In other videos posted by news site Coahuila en línea, shots could be heard ringing out and the army could be seen driving at speed into the town.
The shoot-out lasted for more than an hour and 10 gunmen and four police officers were killed, according to Coahuila Governor Miguel Ángel Riquelme.
Governor Riquelme said that the gunmen took several locals hostage so that they could guide them along the local dirt tracks to aid their escape. Four of those kidnapped have been freed but one adult and one minor remain missing.
Security forces have been trying to track the gunmen down and shot seven more alleged cartel members on Saturday morning on a dirt road.
Governor Riquelme said the gunmen were members of a criminal gang calling itself Cártel del Noreste (Northeast Cartel), an off-shoot of the feared Los Zetas cartel.
Photos posted on social media showed bullet-riddled trucks used by the gunmen with the cartel's initials, CDN, taped to their doors.
Some of the trucks had the cartel's name painted on their number plates
Local media reported that the intended target of the attack was the town's small police force, which only numbers 10 officers, according to Villa Unión's mayor, Narcedalia Padrón.
Mayor Padrón said the town had not experienced such a violent attack before and that she had not been aware of any threats.
While Coahuila state suffered from high levels of violence between 2007 and 2013, in recent years its homicide rate fell to one of the lowest nationwide.
But its location to the south of Texas means that drug cartels fight over the smuggling routes into the US. Villa Unión is located some 60km (37 miles) from the border.
Governor Riquelme says that the security forces are engaged in "an operation to hunt the suspects down". He added that 17 cartel vehicles had been seized.
Speaking in a ceremony on Sunday to mark one year since he took office, President López Obrador did not refer to the incident directly.
He did defend his approach to tackling Mexico's powerful criminal gangs, though, saying that addressing the underlying causes and protecting human rights remained the best way to curb the violence.
He also said that he would not tolerate any intervention from abroad, in a reference to remarks by US President Donald Trump last week that the US was ready to "go in and clear out" the cartels. Mr Trump also said that the US would legally designate Mexican drug cartels as terrorist groups.
Mexico's homicide rate has been on the rise in recent months. Figures for the first nine months of 2019 suggest that this year the homicide toll could surpass that of last year, which had been a record year.