President Trump stops to speak with reporters before heading to a rally in Charlotte on Friday. (Erik S Lesser/EPA-EFE/Shutterstock)

President Trump is preparing to announce a sweeping border crackdown in a speech Tuesday, a week before the midterm elections, in which he is expected to invoke emergency powers to stop migrants from entering the United States and depict them as a grave national security threat, administration officials said Friday.

Trump is considering steps that would bar migrants from crossing the border and deny them a chance to apply for asylum in the United States, measures that legal scholars and immigrant rights groups say would contravene U.S. laws and international treaties, likely triggering challenges in federal court.

The president, undeterred, has been buoyed by rising approval ratings in recent weeks and eager to cudgel his Democratic rivals on border issues, depicting the migrant caravan moving through Mexico as a menace to U.S. security.

Administration officials with knowledge of the speech preparations said the exact measures Trump will announce remain under discussion, as attorneys from the Department of Homeland Security, Justice Department and White House attempt to craft policies that put the administration on the least-vulnerable legal footing.

Trump plans to approach the speech as a chance to lay out his vision for an overhaul of immigration policies and border security, according to aides, eager to whip up his base and convince voters his party will take a firm stand on border security.

Democrats have accused Trump and Republicans of “fearmongering” on immigration ahead of the election.

“President Trump’s immigration policies have been a failure from day one,” House Minority Leader Nancy Pelosi (D-Calif.) said in a statement. “Unlike previous presidents, he has failed to work with our partners in the region, and we are seeing the consequences of his failure today.”

The caravan that has seized Trump’s attention remains more than 900 miles from the U.S.-Mexico border. After peaking at more than 7,000 migrants, according to U.N. estimates, its numbers have dwindled and dissipated over the past several days. Some of those trekking north along the highways of southern Mexico have dropped out, turned back or given up, as the physical strains of the journey take a steep toll, especially on families with small children.

The most recent statements from Mexican officials have said the procession is between 3,000 and 4,000 people and, at its current pace, at least two weeks from the U.S. border.

Some of the migrants could manage to board trucks and hitchhike rides to reach the border sooner, spurred by fears of what Trump may announce.

The Trump administration has pressured Mexico to stop the caravan, and on Friday President Enrique Peña Nieto announced a new initiative called “Make Yourself at Home” that will offer the migrants work permits, medical care and schooling for their children.

Nieto’s carrot came with a stick. On Friday, Mexican federal police arrested 300 Central Americans who were part of a second group of migrants attempting to cross the border from Guatemala, according to local media reports. It appeared to be the first attempt by the government to round up large numbers of Central Americans since the caravan’s arrival and aimed at discouraging more migrants from entering Mexico to join the group.

Mexico’s offer requires migrants to register with the government and remain in the southern Mexican states of Chiapas and Oaxaca, far from the U.S. border.

Tough rhetoric from Trump is also aimed at diminishing the caravan itself, said Dan Stein, president of the Federation for American Immigration Reform, a group that favors tighter immigration laws and supports Trump.

“If he can dissuade all but about 2,500 from coming, then the administration will be a lot better off,” said Stein. “But until they get here he still has the persuasive power of the bully pulpit to convince them they will face a hostile reception, with military troops.”

Stein acknowledged the legal order Trump is considering may not pass muster with the courts.

“Sooner or later he will probably get a court injunction against him,” he said. “But he’s the commander in chief, and he has to do something.”

Attempting to bar people from seeking asylum, if Trump announces such a move, would likely violate the 1980 Refugee Act and a 1967 international refugee treaty that the United States signed, said Philip G. Schrag, a Georgetown University law professor and author of several books on asylum and immigration law.

Federal law says that any immigrant “who is physically present in the United States or who arrives in the United States” — whether at a legal checkpoint or after sneaking across the border — can apply for asylum, he said.

“It’s very unlikely that the courts would hold that the president has the power . . . to prevent people from applying for asylum,” Schrag said. “My prediction is that it would be subject to a temporary injunction of a court within days.”

A draft of the proposal reviewed by The Washington Post says the president can use his authority under Section 212(f) of the Immigration and Nationality Act to declare certain migrants ineligible for asylum for national security reasons.

The section is the same legal authority he invoked during the travel ban, which Trump first issued days after taking office in January 2017 seeking to bar foreigners mainly from certain Muslim-majority countries from coming to the United States for national security reasons.

The ban drew fierce legal challenges and led the administration to issue three different versions before a revised ban was upheld by the Supreme Court on a 5 to 4 vote in June.

The high court ruled that the president has the authority to ban travelers from certain countries to protect the United States, and Trump’s supporters viewed the decision as a major affirmation of his authority.

But others say Central American migrants are not a security threat, and are instead fleeing violence themselves.

“They are coming to the United States in search of protection,” Maureen Meyer, director for Mexico and Migrants Rights at the Washington Office on Latin America, said in a statement. “It’s ridiculous to argue that the babies in the caravan are a national security threat.”

Omar Jadwat, director of the American Civil Liberties Union’s Immigrants’ Rights Project, said the Supreme Court’s travel ban ruling did not give the administration the freedom to bar asylum seekers.

For instance, a foreigner who might have been barred from obtaining a visa to travel to the United States under the travel ban could still seek asylum if they managed to cross the U.S.-Mexico border and set foot on American soil.

“That’s the law,” he said. “You get a chance to explain why you think you are going to be persecuted if you return home.”

Barring a diplomatic breakthrough where the Mexican government agrees to take Central Americans back, the migrants would have to be held in detention until they could be deported. But the United States has virtually nowhere to hold adults traveling with children.

With record numbers of migrant family members arriving in recent weeks, immigration detention capacity is essentially maxed out, and U.S. courts restrict the government’s ability to hold minors in immigration jails for longer than 20 days.

The latest Justice Department statistics show that fewer than 10 percent of Central American applicants are granted asylum by immigration courts, so further limiting their ability to receive it may have a neglibile effect.

Many of the migrant families crossing the border know it’s the act of applying for asylum — not necessarily receiving it — that can allow them to live and work in the United States for several years or longer while their claims went their way through the courts.

The Trump administration has been making preparations to expand family detention capacity by housing detainees on military bases, but those facilities do not appear to be ready.

The Pentagon said in a statement Friday afternoon that it had received a request for assistance from the Department of Homeland Security, and Defense Secretary Jim Mattis has approved “providing mission-enhancing capabilities” along the border.

Under the new troop mobilization, the Pentagon will provide planning assistance, engineering support for the construction of temporary barriers, barricades and fencing, as well as aviation support to move Customs and Border Protection personnel, and protective equipment for border agents.

Seung Min Kim and Dan Lamothe contributed to this report.