A police report into the incident in the southern Chiapas state said the soldiers chased the vehicle after it failed to stop at an army checkpoint before firing gunshots to try and stop it, Reuters news agency reported.
The driver turned off down a dirt road in an attempt to escape, it added, but lost control of the vehicle.
According to the defence ministry’s statement, the migrants came from Egypt, Nepal, Cuba, India and Pakistan. It did not give the nationalities of those who died.
Four died at the scene while two of the 12 people who were wounded died in hospital. The remaining 17 passengers were handed over to immigration authorities.
Officials said federal prosecutors had been informed and a military tribunal would also investigate.
The defence ministry said it was committed to “act in strict accordance with the rule of law, under a policy of zero-impunity, and ready to help the civil authorities to shed light on the facts”.
Thousands of migrants travel through Mexico each year in buses, overcrowded lorries and on freight trains as they try to get to the US-Mexican border.
They run the risk of fatal accidents, kidnapping by criminal groups and extortion by corrupt officials.
In December 2021, a people smugglers’ lorry overturned in Chiapas killing 56 mostly Central American migrants.