They migrants told police they had been held for hours by armed men who stopped their bus, but later fought back and broke free from their captors.
Kidnappings are common in Mexico with gangs often abducting migrants and forcing them to join their ranks.
Tens of thousands of migrants travel through Mexico on their way to the US every year.
Many are forcibly recruited into gangs. Others are held until their families pay for their release.
The migrants said armed men posing as members of the security forces boarded their bus near the town of Ocotlan, in the southern state of Oaxaca on Saturday.
The migrants say they were taken to a car pound where their captors stole their belongings and attacked at least one woman.
According to the migrants, after about six hours they overpowered the gang members, delivering kicks and punches.
Many then fled into the surrounding hills. Some came across a police patrol, which they attacked, reportedly thinking they were part of the gang that had kidnapped them.
At least 37 migrants were arrested by police and handed over to local migration authorities.
It is not clear how many people were held by the gang, but some local media put the number as high as 100.
Police said they were from Central America and had been trying to reach the US.
So far, none of the armed men who held the migrants captive have been caught.
Dozens of Central American migrants say they have managed to escape from a gang that abducted them in southern Mexico.