The smugglers told the foreigners that if they did not provide a phone number with which they could demand money from relatives, they would be handed over to organised crime gangs, said a statement from the state security commission.
Police were alerted by a Guatemalan man who said he escaped from the house where the foreigners were being held.
The captors were Central Americans, the statement said.
Those being held were from Guatemala, El Salvador, Honduras, Nicaragua, Sri Lanka and India and included women and children.
More From This Section
Every year some 200,000 undocumented foreigners, most of them Central American, enter Mexico trying to make their way to the United States.
The trip is extremely dangerous, with the travelers braving threats from crime gangs that kidnap, extort and sometimes murder them, according to the National Human Rights Commission.
In August 2010, 72 immigrants from Central and South America were massacred by a drug cartel called Los Zetas after their relatives failed to pay ransom and the captives refused to join the gang, according to the official probe.