Mexico's foreign ministry presented a diplomatic note to the US government on Monday calling for "a full investigation" into what it described as non-lethal weapons directed toward Mexican territory on Sunday, a statement from the ministry said.

The formal request came a day after US authorities fired tear gas canisters toward migrants in Mexico — near the border crossing separating Tijuana from San Diego, California — when some rushed through border fencing into the United States.

More than 40 were arrested on the US side, US border authorities said, adding that none were believed to have successfully crossed further into Californian territory.

US President Donald Trump told reporters at an event in Mississippi that he would close the border if migrants "charge" the barrier. During the melee on Sunday, US authorities shut San Ysidro, the country's busiest border crossing, for several hours.

"We would close it and we'll keep it closed if we're going to have a problem. We’ll keep it closed for a long period of time," Trump said.

Related: Why does the migrant 'caravan' exist? And how did it come to be?

Sunday's incident was the latest chapter in a saga that has pitted Trump's hardline immigration policies against thousands of migrants who have made their way north through Mexico from violent and impoverished Central American countries.

Tensions had been growing in Tijuana, and the president said on Saturday the migrants would have to wait in Mexico until their individual asylum claims were resolved in the United States. That would be a significant shift in asylum policy that could keep Central Americans in Mexico for more than a year.

Trump went further on Monday, saying Mexico should send the Central Americans, mostly Hondurans, back home.

"Mexico should move the flag-waving migrants, many of whom are stone cold criminals, back to their countries. Do it by plane, do it by bus, do it any way you want, but they are NOT coming into the USA. We will close the border permanently if need be. Congress, fund the WALL!" Trump tweeted.

Mexico has been in negotiations with the United States over a possible scheme to keep migrants in Mexico while their asylum claims are processed.

The team of Mexican President-elect Andrés Manuel López Obrador, who takes office on Saturday, has said no deal has been agreed on the migrants. But officials have hinted they could remain.

"We should be objective, whatever happens, they will stay in Mexico," said Alejandro Encinas, an incoming deputy interior minister. "Migrants have rights and we will respect them."

US government agencies defended the response to Sunday's incident at the San Ysidro crossing south of San Diego. News pictures showing children fleeing tear gas prompted sharp criticism from some lawmakers and charities.

British aid group Oxfam said the use of tear gas was shameful.

"Images of barefoot children choking on tear gas thrown by US Customs and Border Patrol should shock us to our core," Vicki Gass, Oxfam America senior policy advisor for Central America, said in a statement.

Democrats and other critics called the use of tear gas an overreaction and questioned the idea of keeping the migrants in Mexico to make asylum claims there.

Related: US troops’ arrival prompts unease on both sides of the border in Arizona

Some rights advocates and legal experts were concerned that the Trump administration was seeking to exploit the clashes.

Geoffrey Hoffman, a professor and director of the University of Houston Law Center Immigration Clinic, which represents migrants applying for asylum, said the government would use it to push the argument that the migrants should remain in Mexico.

Still, Rodney Scott, chief US Border Patrol agent in San Diego, told CNN the vast majority of those assembled at the border were economic migrants who would not qualify for asylum and said there were few women and children.

"What I saw on the border yesterday was not people walking up to Border Patrol agents and asking to claim asylum," he said.

US Department of Homeland Security Secretary Kirstjen Nielsen said in a statement that the agency has "confirmed that there are over 600 convicted criminals traveling with the caravan."

She also said the women and children in the "caravan" were being used as "human shields" by organizers when they confront law enforcement.

CBP Commissioner Kevin McAleenan said in a statement four agents were hit with rocks on Sunday, but they did not suffer serious injuries.

Waiting game

Tijuana police chief Mario Martinez told a news conference on Monday that 194 Central Americans had been arrested in the 15 days the group of migrants has been in the area.

The migrants have traveled through Mexico in large groups, or "caravans." There are more than 7,000 migrants at the US border in Tijuana and the city of Mexicali, with more than 800 others still moving toward the border.

Tijuana Mayor Juan Manuel Gastelum, who has said his city is facing a humanitarian crisis, told a local radio station the United States would take up to three months to start processing asylum requests.

Many of those in Tijuana have said they will wait there until they can seek asylum. If they enter the United States — legally or illegally — they have a right to seek asylum.

Melkin Gonzalez, a 26-year-old Honduran man, recounting Sunday's tear gas firing, said: "I fell in dirty water when I was running [away] and I still don't have any clothes to change into. Even so, I'm not going back to Honduras, I want to go to the United States."

The US military said it had shifted about 300 service members from Texas and Arizona to California in recent days. In total, about 5,600 active-duty troops are on the border with Mexico. US military officials have said they expected troops to be repositioned as the situation developed and changed.

Nielsen said her agency was prepared to address any future violence by deploying more US military forces.

US lawmakers face a deadline to approve funding for the federal government by Dec. 7. Trump has threatened to shut down the government unless Congress pays for his planned border wall.

Next: They took sanctuary in a Connecticut church — but did not hide from immigration officers