Thousands of people travelling across Central America en masse to the US are stuck on Mexico's southern border after a failed attempt to enter the country.
Some of them broke through Guatemalan border fences but then clashed with Mexican riot police in no man's land.
On Friday, US President Donald Trump thanked Mexico for its efforts in stopping the caravan of migrants.
The migrants, mostly from Honduras, say they are fleeing violence and poverty, and include women and children.
President Trump, who has threatened to close down the US border and cut aid to countries allowing the caravan to pass, said the military would be called upon if needed.
"They might as well turn back, they're not coming into this country," he told reporters on Friday.
After talks on border security in Mexico, Secretary of State Mike Pompeo said the situation was reaching "a moment of crisis".
What happened on the border?
Many of the migrants temporarily broke through barriers on a bridge which crosses the river border between Guatemala and Mexico.
Dozens of Mexican police in riot gear fired tear gas to force them to retreat into no-man's land after being attacked with stones.
A number of migrants jumped into the Suchiate river to reach rafts, while others either turned back towards Guatemala or simply sat down on the bridge.
Several people were reportedly injured in the clash, including migrants, police and journalists.
One woman nursing a baby told AFP she had lost two of her children in the chaos.
"We're running away from violence, and we arrive here and they just hit us more," Marta Ornelas Cazares, 28, said.
"I don't know what happened, I thought we were going to cross peacefully and then suddenly there were rocks flying and tear gas."
The Mexican authorities said those with valid passports and visas would be allowed in immediately, though this is believed to apply to only a minority of the migrants.
They warned that anyone without papers would have to apply for refugee status or turn back, and anyone who crossed illegally would be detained and deported.
According to AFP, they started to allow a small number of people - including women and children - who were seeking refugee status to pass the border late on Friday. They were put on to trucks and taken into shelters.
What will happen to them now?
Honduran President Juan Orlando Hernandez said he had spoken to his Guatemalan counterpart and asked permission to send his country's civil protection force to the area to help the migrants.
"I also asked for authorisation to hire ground transportation for anyone who wants to return and an air bridge for special cases of women, children, the elderly and the sick," Hernandez tweeted.
The two leaders are due to meet later on Saturday to discuss the situation.
Mexican President Enrique Pena Nieto said the border clash was "unprecedented" and accused some of the migrants of attacking police.
Human rights groups have criticised the US and Mexican response to the caravan.
Erika Guevara-Rosas of Amnesty International said in a statement: "These families deserve dignity and respect to ensure that no-one is illegally returned to situations where they could risk serious harm due to violence."
Why is Trump concerned?
Since his campaign days, Mr Trump has lambasted illegal immigrants, and this latest caravan comes after a major immigration crackdown.
Changes to detention rules saw thousands of migrant children detained and separated from their parents at the US-Mexico border earlier this year, sparking national and international condemnation.
Mr Trump's threats come weeks before the mid-term elections on 6 November, which could see Democrats unseating Republicans in the House of Representatives.
According to a Kaiser Foundation poll, immigration is the most important issue for 15% of all voters, though the number jumps to 25% among Republican voters.
While Mr Trump has sent National Guard troops to the border before, it is unclear what he means by shutting it down entirely, and whether that would affect businesses or people with legitimate visas.
And according to international law, the US cannot deport asylum seekers without first determining the validity of their claim.
Why are they leaving?
An estimated 10% of the population of Guatemala, El Salvador and Honduras have fled danger, forced gang recruitment and dismal economic opportunities.
The region has one of the highest murder rates in the world. The UN reported murder rates in 2015 in Honduras standing at 63.75 deaths per 100,000 and El Salvador at 108.64 deaths.
Jari Dixon, an opposition politician in Honduras, tweeted on Monday that the caravan was not "seeking the American dream" but "fleeing the Honduras nightmare".
In a statement on Tuesday, Honduras' foreign ministry urged its citizens to "not let themselves be used by a movement that is clearly political and seeks to disrupt the governability, stability and peace".