Veracruz state Attorney General Reynaldo Escobar Perez said the bodies were left piled in two trucks and on the ground of an underpass near a shopping mall in the city of Boca del Rio.
Police had identified seven of the victims so far and all had criminal records for murder, drug dealing, kidnapping and extorsion and were linked to organized crime, Escobar said. He didn't say to what group the victims belonged to.
The Zetas drug cartel has been locked in a bloody war with drug gangs for control of Veracruz, a state along an important route for drugs and Central American migrants heading north.
Motorists first began tweeting Tuesday afternoon that masked gunmen in military uniforms were blocking Manuel Avila Camacho Boulevard in Boca del Rio's downtown and pointing their guns at civilians.
"They don't seem to be soldiers or police," a tweet read. Another said, "Don't go through that area, there is danger."
Escobar said police were reviewing surveillance video recorded in the area.
Local media said that 12 of the victims were women and that some of the dead men had been among prisoners who escaped from three Veracruz prisons on Monday, but Escobar said he couldn't confirm that.
At least 32 inmates got away from the three Veracruz prisons. Police recaptured 14 of them.
Earlier Tuesday, the Mexican army announced it had captured a key figure in the cult-like Knights Templar drug cartel that is sowing violence in western Mexico.
Saul Solis Solis, 49, a former police chief and one-time congressional candidate, was captured without incident Monday in the cartel's home state of Michoacan, Brig. Gen. Edgar Luis Villegas said during a presentation of Solis to the media.
Solis is considered one of the principal lieutenants in the Knights Templar, which split late last year from La Familia, a pseudo-religious drug gang known as a major trafficker of methamphetamine.
He is accused in various attacks on the military and federal police, including one in May 2007 that killed an officer and four soldiers, Villegas said. Solis also is suspected of planting and harvesting drugs, managing clandestine labs manufacturing synthetic drugs and ordering attacks on police facilities in cities around the entire state.
Mexico's attorney general had offered a $1.1 million reward for information leading to his capture.
Solis is a cousin of one of the Knights Templar's main alleged leaders, Enrique Plancarte Solis. Saul Solis served as director of public safety in the Michoacan town of Turicato in 2003-05 and ran for the federal congress in 2009 as a Green Party candidate, finishing fourth in his district with about 11,000 votes.
Authorities said a judge had issued an arrest warrant for Solis on charges of organized crime and drug trafficking at the time of the vote.
President Felipe Calderon launched an offensive against organized crime in 2006 in his home state of Michoacan, where much of the violence had been attributed to La Familia. Knights Templar became a splinter group after the leader of La Familia, Nazario Moreno Gonzalez, was killed in a shootout with federal police last December.
A second La Familia leader, Jose de Jesus Mendez Vargas, was arrested in June, leading Calderon's government to say it had all but dismantled the gang. But violence continues in Michoacan and other parts of western Mexico where Knights Templar is trying to control territory.
Both groups claim to be devoted to God and to be fighting poverty and injustice under a strict code of conduct.
Late Monday, four gunmen died in a clash between drug cartels in the Michoacan towns of Caracuaro and Tiquicheo, the army said in a statement. It said residents told authorities several vehicles packed with gunmen had been seen in the area earlier Monday.
Drug violence has claimed more than 35,000 lives across Mexico since 2006, according to government figures. Others put the number at more than 40,000.
In northern Mexico, the army announced the detention of two more suspects in a casino fire that killed 52 people last month in the northern city of Monterrey.
The two men captured at a bar in Monterrey late Monday confessed to being members of the Zetas drug cartel and participating in the attack, federal prosecutors said.
Six others, including a Nuevo Leon state police officer, previously were arrested in the case and 16 more suspects remain at large.
Last week, the parents and a brother of a police officer involved in the casino investigation were shot to death at their Monterrey home. Authorities said the attack could have been revenge because the officer helped identify some of the alleged attackers.
Separately in Nuevo Leon, Mexican marines captured 19 alleged members of the Zetas drug cartel at a ranch that was being used as a training camp in the town of Colombia, the military announced.
A navy statement said that seven minors were among those detained and that marines seized four rifles, a pistol, and several military uniforms and boots.