WASHINGTON — 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 try 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.