The move comes after US President Donald Trump threatened to impose tariffs on Mexico if it could not control illegal migration across the border.
Mexico has deployed nearly 15,000 soldiers and National Guardsmen to its border with the United States, the army chief said on Monday - admitting they are detaining migrants who try to cross after the policy triggered a backlash.
Under pressure from US President Donald Trump to slow the surge of Central Americans crossing the border, Mexico promised earlier this month to reinforce its southern border with 6000 National Guardsmen but had not previously disclosed the extent of the crackdown on its northern border.
"We have a total deployment, between the National Guard and army units, of 14,000, almost 15,000 men in the north of the country," Defense Minister Luis Cresencio Sandoval said at a press conference alongside President Andres Manuel Lopez Obrador.
Asked whether those forces were detaining migrants to prevent them from crossing, Sandoval replied: "Yes."
"Given that (undocumented) migration is not a crime but rather an administrative violation, we simply detain them and turn them over to the authorities" at the National Migration Institute, he said.
The government has faced criticism for stopping migrants from crossing the US-Mexican border.
National Guardsmen and police have been patrolling the border in groups, detaining migrants who attempt to cross.
The policy is a shift from previous practice. The Mexican security forces have long detained undocumented migrants as they travel in the country, but had not typically stopped them from crossing the US border in the past.
The practice caused an outcry after an AFP photographer documented last week how heavily armed National Guardsmen in Ciudad Juarez forcefully stopped two women and a young girl from crossing the Rio Grande river into the United States.
In some cases, migrant families have been separated when some members manage to cross the border and others get detained on the Mexican side.
'Doing the US's dirty work'
Mexico "is doing the United States's dirty work," Francisco Javier Calvillo, the head of the migrant shelter Casa del Migrante in Ciudad Juarez, told journalists in reaction to the new practice.
"That's not the army's job, the federal police aren't trained to deal with migrants ... This policy is a clear violation of human rights," added Calvillo, a Catholic priest.
Fleeing chronic poverty and brutal gang violence in their home countries, the Central Americans crossing Mexico mostly lack migration papers.
However, international law protects the right of undocumented migrants to cross international borders to request asylum.
And the US courts have upheld their right to do that anywhere along the border, whether or not it is an official crossing.
There has been a large increase in such migrants crossing the US-Mexican border and seeking asylum in recent months.
American officials detained 144,000 migrants at the border in May, up 32 per cent from April and 278 per cent from May 2018.
The total included a record 89,000 families.
Trump wants Mexico to do more to reduce that number.
Last month, he threatened to impose tariffs on all Mexican goods, extracting a promise from Lopez Obrador's government to reinforce Mexico's southern border and expand its policy of taking back migrants while the US processes their asylum claims.
The deal, struck on 7 June, gives Mexico 45 days to show results.