WASHINGTON — President Donald Trump said Thursday that U.S. troops he dispatched to the nation's border will use lethal force to stop migrants attempting to enter the country "if they have to."

Earlier this week, Trump authorized the military to use its rules of engagement, rather than those of domestic law-enforcement agencies, at the border.

"If they have to, they're gonna use lethal force," he said. "I've — I've given the okay. If they have to. I hope they don't have to."

He added that he will "close entry" at the border if he deems it necessary to prevent immigration. Just before the midterm elections earlier this month, Trump sent thousands of troops to the U.S.-Mexico border in response to the advance of caravans of migrants through Latin America.

Critics of Trump's use-of-force policy have noted that it runs the risk of entering a thicket of federal statues, constitutional principles and international law - most notably the Posse Comitatus Act, which, with some exceptions, precludes the military from domestic law-enforcement activities.

"The Posse Comitatus Act keeps the President from using troops to enforce domestic policy. For all the obvious reasons." Joyce White Vance, a former federal prosecutor and MSNBC contributor, wrote on Twitter Wednesday. "It was enacted in 1878. Only Trump would think to violate it & as all things with Trump, once you violate a norm, it's a fast slide down the slippery slope."

Trump, who has been frustrated with congressional refusal to provide funding for the border wall he promised to build between the U.S. and Mexico, has repeatedly portrayed migrants fleeing Central America as an invading force.

Most Democrats and some Republicans oppose the border wall, and House Democrats' victory in the midterms means that he is less likely to get the money he is seeking for a border wall.

Trump said he will entirely close the border — to people and trade — if Mexico doesn't stop migrants from trying to come into the U.S.

"We will close the border, and that means the Mexico's not going to be able to sell their cars into the United States until it's open," he said Thursday. "But we're going to need to have a border or we're not. And when they lose control of the border on the Mexico side, we just close the border."