President Trump offered Mexico some advice on deporting migrants massed in Tijuana and threatening to storm the U.S., telling the neighboring nation in a tweet to send them “back to their countries” by plane or by bus – or face a permanent closure of the border.

Trump’s tweet followed a vow from Mexico to deport migrants who tried to illegally enter the U.S. The Trump administration has said asylum claims from members of a series of caravans originating in Central America must be processed outside the U.S., and that all those entering illegally will be denied. A federal judge has at least temporarily ruled against the policy, but the administration has taken steps to harden the border.

“Mexico should move the flag waving Migrants, many of whom are stone cold criminals, back to their countries,” Trump tweeted early Monday morning. “Do it by plane, do it by bus, do it anyway you want, but they are NOT coming into the U.S.A. We will close the Border permanently if need be. Congress, fund the WALL!”

The missive came after a chaotic Sunday that saw hundreds of migrants from a caravan that originated in Central American pushing past Mexican riot police and rushing the border at the port of entry in San Ysidro, Calif., in a major test for both U.S. border authorities and Mexican officials.

U.S. Customs and Border Protection (CBP) said it suspended northbound and southbound crossings for both pedestrians and vehicles at the San Ysidro port of entry at approximately 11:30 a.m. local time. It later tweeted that the pedestrian crossings had re-opened, a little more than four hours after the initial closure. The vehicle lanes re-opened at approximately 5 p.m. local time, five-and-a-half hours after they were closed.

CBP added that some demonstrators "attempted to illegally enter the U.S. through both the northbound and southbound vehicle lanes at the port of entry itself. Those persons were stopped and turned back to Mexico."

U.S. border agents shot several rounds of tear gas after some migrants attempted to penetrate various points along the border and threw what appeared to be rocks at U.S. authorities.

Homeland Security Secretary Kirstjen Nielsen said in a statement that some migrants "attempted to breach legacy fence infrastructure along the border and sought to harm CBP personnel by throwing projectiles at them.

"As I have continually stated, DHS will not tolerate this type of lawlessness and will not hesitate to shut down ports of entry for security and public safety reasons," Nielsen said. "We will also seek to prosecute to the fullest extent of the law anyone who destroys federal property, endangers our frontline operators, or violates our nation’s sovereignty."

The Mexican Interior Ministry said Sunday it would immediately deport the migrants who tried to "violently" breach the border. The Mexican government described Sunday's events as "acts of provocation" that were "far from helpful" for the migrants' objectives.

The situation Sunday was not unprecedented. In 2013, during the Obama administration, Border Patrol agents used pepper spray to fend off a crowd of approximately 100 migrants who attempted to rush the San Ysidro port of entry. The migrants in that episode also reportedly threw rocks and bottles at U.S. authorities.

Within an hour on Sunday, the group from the caravan that rushed toward the border largely dispersed. Most of the migrants in the group were men.

The prospective deal between the U.S. and Mexico was seen as a way to dissuade thousands of Central American migrants from seeking asylum in the U.S., a process that can take years. The legal bar for claiming asylum is high and generally requires applicants to show a specific risk of persecution based on factors such as race, nationality, politics or religion.

Trump administration officials have characterized the vast majority of asylum claims as fraudulent or legally insufficient, and have taken steps to reduce the backlog of asylum claims that they say are often used by migrants to gain entry into the U.S. and disappear into the country as their claims are adjudicated.