President Trump threatened Monday to close the southern border “permanently” unless Mexico sends asylum-seekers — many of whom he described as “stone cold criminals” — back to where they came from.

“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 anyway you want, but they are NOT coming into the U.S.A.,” the president said in a tweet.

“We will close the Border permanently if need be. Congress, fund the WALL!” he added.

Trump’s latest threat to seal off the border comes a day after US Border Patrol agents fired tear gas at Central American migrants who tried to storm through a border fence at the San Ysidro crossing that links San Diego with Tijuana, Mexico.

Authorities temporarily closed the port of entry “to ensure public safety” after some of the migrants threw “projectiles” at agents as they bore down on the fence, officials said.

“Border Patrol agents deployed tear gas to dispel the group because of the risk to agents’ safety,” the agency said on Twitter.

On Sunday, Mexico promised to shore up security along the border, and the country’s Interior Ministry said it would immediately deport those who tried to “violently” enter the US from Tijuana.

More than three dozen migrants were arrested for disturbing the peace and other charges after the chaotic scene Sunday.

Mexico’s Ministry of the Interior said later that 98 people who were caught and turned over to the authorities would be deported to their countries of origin because of the “violent behavior of a group of migrants who tried to attack and injure” US Border Patrol officers.

The Mexican government also said it was trying to find others involved in Sunday’s incident and “carry out their immediate deportation,” if appropriate.

Furthermore, Mexico shored up security near the US border as police lined up outside a shelter in the city of Tijuana and told the migrants they couldn’t walk toward the border area.

Customs and Border Protection Commissioner Kevin McAleenan said on a call with reporters that 69 migrants who crossed the border illegally were arrested on the California side.

He said the Border Patrol’s policy allows agents to use tear gas and other nonlethal methods, but noted the situation was resolved without serious injury. Still, the incident will be reviewed.

“As the events unfolded, quick, decisive and effective action prevented an extremely dangerous situation,” McAleenan said.

As news pictures showing children fleeing tear gas prompted sharp criticism from some lawmakers and human-rights advocates, the government defended the response.

“What I saw on the border yesterday was not people walking up to Border Patrol agents and asking to claim asylum,” said Rodney Scott, chief Border Patrol agent in San Diego.

The migrants, mostly Hondurans, have traveled to the border in large groups and now number more than 8,000.

Many of the thousands who have gathered 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.

Homeland Security Secretary Kirstjen Nielsen said US authorities will continue to have a “robust” presence along the southwest border and that anyone who damages federal property or violates American sovereignty would be prosecuted.

“DHS will not tolerate this type of lawlessness and will not hesitate to shut down ports of entry for security and public safety reasons,” she said.

Trump also took to Twitter on Sunday to express his displeasure with the caravans.

“Would be very SMART if Mexico would stop the Caravans long before they get to our Southern Border, or if originating countries would not let them form (it is a way they get certain people out of their country and dump in U.S. No longer),” he wrote.

“Dems created this problem. No crossings!”

With Post wires