The Defense Department said in a statement that soldiers chased the five assailants and returned fire whey they were "attacked," killing all of the gunmen.
The army said the gunmen, who were carrying rifles, started the attacks in the pre-dawn hours of Thursday, killing three people who were loading vegetables into a truck in the town of El Higo, in northern Veracruz. In the same town, they tossed a grenade that killed another person.
Later, the gunmen went to a nearby highway, stopped and robbed a bus and killed two of the passengers aboard, according to the army statement.
They later stopped another bus and sprayed it with gunfire, killing four passengers. When the driver of a third bus stopped and got off to see what was happening, they killed him too.
Veracruz state government spokeswoman Gina Dominguez said that while the gunmen's identities and cartel affiliation have not yet been established, the men killed match witness descriptions of the assailants in the bus attacks, Dominguez said.
The bloody pre-Christmas bus shootings brought up memories of the brutal murder of dozens of bus passengers whose bodies were found in mass graves in the neighboring state of Tamaulipas in April. A total of 193 bodies had been found in 26 graves, and officials say most of those were Mexican migrants heading to the United States who were kidnapped off buses and killed by the Zetas drug cartel.
In the Tamaulipas killings, the Zetas gunmen stopped and boarded buses and removed male passengers and killed them, either because they believed a rival gang was trying to send reinforcements into the region aboard buses or because they wanted to force some of the passengers to join their gang.
The buses attacked Thursday were covering local routes in northern Veracruz, though authorities did not release the names of the bus lines operating the route.
There was no immediate information on the identity of the dead bus passengers, or the four people killed in El Higo.
The area has been the scene of bloody battles between the Zetas and their former allies, the Gulf cartel.
The two gangs split in 2010.
The U.S. Consulate General in Matamoros, a Mexican border city north of where the attacks occurred, said in a statement that "several vehicles," including the buses, were attacked, but did not specify what the other vehicles were.
The consulate urged Americans to "exercise caution" when traveling in Veracruz, and "avoid intercity road travel at night."
While the specific area where the Thursday attacks occurred is not frequented by foreign travelers, it adjoins an area to the west known as The Huasteca that is popular among Mexican tourists and some foreigners.