Mexico will deport Central American migrants who attempted to storm the US border, its interior ministry said.
The group, part of the migrant caravan heading towards the US from Central America, was rounded up after trying to cross the border “violently” and “illegally” on Sunday.
Video footage shows dozens of people running towards the border fence near the city of Tijuana.
US border officers used tear gas to repel them.
On Monday US officials confirmed that 42 people who managed to cross on Sunday had been arrested.
US President Donald Trump also reiterated a threat to close the border completely.
Who are the migrants?
Tension has been running high on the US-Mexican border since the arrival of almost 7,500 migrants over the past weeks.
The migrants, who are mostly from Honduras, but also from Guatemala and El Salvador, say they are fleeing the threat of violence in their home countries and looking to make a better life for themselves and their families.
They have travelled in large groups, dubbed “caravans”, for more than 4,000km (2,500 miles) from Central America and most want to reach the United States, where they say they plan to ask for asylum.
Among them are many families with young children.
President Trump has vowed to keep each migrant on the Mexican side of the border until courts have decided their cases, meaning some face a long wait.
They have been spending the past two weeks in temporary shelters in the Mexican border city of Tijuana and in Mexicali, 180km to the east along the border.
How did events unfold?
A group of at least 500 migrants joined a march from their shelter in Tijuana towards the border on Sunday.
Mexican Interior Minister Alfonso Navarrete said the migrants had asked for help to organise the demonstration but were then reportedly encouraged by some of the movement’s leaders to split into different groups so they could make a run for the border and try to cross into the US.
The march started peacefully with migrants carrying pro-immigration banners and shouting: “We aren’t criminals! We are hard workers!”.
But once they managed to get past the security cordon, the march quickly turned into a dash for the border, BBC correspondent Will Grant reports.
Several hundred managed to climb over the first barrier, according to Agence France-Press news agency. It was as they tried to cross a second, spike-topped wall that officials on the US side began firing tear gas.
An AFP journalist saw the migrants – including mothers and children – trying to protect themselves from the gas, with some crying out that they only wanted to find work and a better life in the US.
Associated Press Mexico correspondent Chris Sherman said he had seen parents running away with choking toddlers. Among them was Honduran migrant Ana Zuniga, 23, and her three-year-old child: “We ran but when you run, the smoke smothers you more.”
US Customs and Border Protection, which polices the border, said its personnel had been assaulted and hit by rocks.
Homeland Security Secretary Kirstjen Nielsen defended her agency’s actions.
Chief Patrol Agent Rodney Scott told CNN on Monday that dozens of migrants that successfully made it into US territory were arrested.
“There were sections that had dilapidated border wall that was made out of scrap metal the military gave us,” he said.
“The group breached a couple of sections of that, actually tore down one small section.”
What was the US reaction?
As a result of Sunday’s action, the US closed the San Ysidro border crossing near Tijuana to vehicles and pedestrians for a number of hours, causing long delays in both directions.
US Homeland Security Secretary Kirstjen Nielsen said the migrants had tried to harm US border guards “by throwing projectiles at them”.
She said the department would “not tolerate this type of lawlessness and will not hesitate to shut down ports of entry for security and public safety reasons” and that US officials would “seek to prosecute” offenders.
Mr Trump threatened to close the entire US-Mexico border earlier this week if it was felt the US was going to “lose control” of the situation.
He reiterated the threat on Monday after the incident, saying he would “close the border permanently if need be”.
He has also said he has given troops at the border the go-ahead to use lethal force if needed.
What did Mexico say?
Mexico’s interior ministry said in a statement that those identified as having taken part in these “violent events” would be deported immediately.
The ministry added that, “far from helping their objectives”, the migrants’ actions had violated the legal migration framework and could have led to a “serious incident”.
With the Mexican authorities saying that those who crossed illegally into the US on Sunday face “immediate” deportation, the mood in the migrant shelter is likely to darken, says the BBC’s Will Grant.
Many in the migrant caravan are likely to be unsettled by this turn of events, our correspondent says.
And with many in the shelters realising how long the wait for asylum could be, some, like Honduran Joseph García, are growing increasingly desperate: “My little girl is sick and I don’t even have money for milk. I can’t stand it anymore.”