President Donald Trump said Thursday he planned to sign an executive order next week tightening asylum rules — and urged U.S. troops at the border to fire on migrants if they threw rocks.

The comments, made in a speech at the White House, continued Trump’s hard-line anti-immigration rhetoric ahead of the midterms, including attempts to whip up fears over a caravan of Central American migrants headed for the U.S. border.

Trump said his team was preparing an executive action that would restrict asylum claims to legal ports of entry, preventing undocumented migrants from claiming asylum if caught crossing the border illegally.

He said the measure was to address “rampant abuse” of the system but offered no details on how the order, which would inevitably face a legal challenge, would work. Current U.S. immigration laws allow anyone who arrives in the country, “whether or not at a designated port of arrival” to apply for asylum if they have a well-founded fear of persecution in their home country.

Trump also raised the prospect that U.S. troops could fire on members of the caravan should they reach the border.

Referring to reported clashes between security forces and the migrants as they crossed from Guatemala into Mexico, Trump said U.S. troops would fight back against any rocks being thrown at them.

“They want to throw rocks at our military, our military fights back,” the president told reporters. "I told them to consider it a rifle. When they throw rocks like what they did to the Mexican military and police, I say: Consider it a rifle.”

Asked if he thought it likely soldiers would open fire on the migrants, he said: “I hope not — but it's the military.”

The remarks prompted derision from veterans online, who pointed out that shooting rock-throwing civilians would violate the rules of engagement.

U.S. military rules only allow deadly force to be used in cases where the target poses an imminent threat of death or serious injury.

But in cases where U.S. border forces have fired over the border before, that’s proven something of a grey area, with agents asked to take in the "totality of the circumstances, to include the size and nature of the projectiles" to determine whether there's an imminent danger.

Trump has ordered thousands of additional soldiers to the southern border in recent weeks, raising concerns it could set a dangerous precedent. He said Wednesday that the surge could eventually involve 15,000 troops, which would be the largest domestic deployment of active soldiers in modern U.S. history. Meanwhile, some senior-level Defense Department officers think the move is politically-motivated and a waste of money, according to internal Pentagon documents obtained by Newsweek.

Trump has also threatened to close border crossings, and cut funding to the migrants’ countries of origin. Tent cities would be used to house any asylum seekers, he also warned.

Continuing the hard-line approach, Trump promoted a widely criticized political ad Wednesday that implied members of the migrant caravan could be cop killers. The spot, panned as racist and fear-mongering, was also factually inaccurate.