Mexico will deport almost 500 migrants who attempted to storm the US border, according to its interior ministry.
The group were rounded up after trying to cross the border "violently" and "illegally" on Sunday local time (Monday NZDT), the ministry said in a statement.
Video footage shows dozens of people running towards the fence that separates the two countries near the city of Tijuana, while photos show clouds of tear gas rising into the air.
The migrants - including many women and children - are in Tijuana after travelling more than 4000km from Central America.
Mexico's interior ministry said all those who were identified as having tried to cross would be deported immediately.
It added that, "far from helping their objectives", the migrants' actions had violated the legal migration framework and could have led to a "serious incident".
Earlier, the US Customs and Border Protection agency said traffic in both directions was suspended at the San Ysidro port of entry.
US President Donald Trump has raised alarms about a caravan of Central American migrants as it approached the United States, with its members planning to apply for asylum on reaching the United States.
Tensions on the border had been rising in recent days, with more than 5000 migrants camped out at a sports complex in Tijuana and hundreds periodically gathering near the main border crossing.
They say they are fleeing persecution, poverty and violence in their home countries of Honduras, Guatemala and El Salvador.
However, they now face a long wait to see if their asylum applications will be accepted by the US, with President Donald Trump vowing to keep each migrant on the Mexican side of the border until courts have decided their case. This could take months.
The migrants have said they would wait there until they could request asylum despite growing US measures to tighten the border.
On Sunday, hundreds of caravan members were peacefully protesting when they were stopped by Mexican authorities, who told them to wait for permission.
As the morning wore on, and it became clear they would not get permission, people started to express frustration.
A small group broke off and headed to a part of a canal between Tijuana and San Diego that led to the border fence.
At that point, before the group had reached the border, US Customs and Border Protest officers on the other side of the fence launched canisters of what a Reuters reporter said felt and smelled like pepper.
According to news agency AFP, a number managed to climb over a first fence. It was as they tried to cross a second, spike-topped wall that officials on the US side began throwing 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 a work and a better life in the US.
AP journalist Chris Sherman said he had seen parents running away with choking toddlers.
Honduran migrant Ana Zuniga, 23, tried to cross with her three-year-old.
"We ran but when you run the smoke smothers you more," she said.
Protesters were caught between the Mexican and US authorities. A young woman fell to the ground unconscious and two babies cried, tears streaming from the gas.
After running to relative safety nearby, hundreds of the caravan members held a sit-in.
Later, immigrants again approached the border in groups and were met by a further volley of canisters emitting large clouds of gas.
Tijuana Mayor Juan Manuel Gastelum on Friday declared a humanitarian crisis in his border city of 1.6 million, which he says is struggling to accommodate the crush of migrants.
Mr Trump tweeted on Saturday that migrants at the US-Mexico border would stay in Mexico until their asylum claims were individually approved in US courts, but Mexico's incoming government denied they had struck any deal.
US Customs and Border Patrol officers gathered on the US side in a show of force.
Last week the US temporarily closed the busy border crossing to install new movable wire-topped barriers.
Thousands of migrants - including women and children - are currently at the US-Mexico border after travelling more than 4000km from Central America, the BBC reported.
They say they are fleeing persecution, poverty and violence in their home countries of Honduras, Guatemala, and El Salvador.
Many are now waiting in temporary shelters in the border city of Tijuana, leading the mayor declare a humanitarian crisis. There are fears as many as 9000 may be stuck in the city for months.
Meanwhile, Mr Trump has deployed about 5800 troops to the border and has previously described the migrants as an "invasion".
- Reuters / BBC