WASHINGTON — President Donald Trump threatened to summon the military to close the U.S.-Mexico border and upend a trade deal, expressing mounting frustration with a large caravan of migrants from Honduras making its way toward the United States.

In tweets Thursday, Trump repeated vows to stop U.S. aid to Central American countries that do not disband the caravan and issued a fresh threat to the Mexican government, which said Wednesday that it would treat those in the caravan no differently than it does other migrants.

“In addition to stopping all payments to these countries, which seem to have almost no control over their population, I must, in the strongest of terms, ask Mexico to stop this onslaught — and if unable to do so I will call up the U.S. Military and CLOSE OUR SOUTHERN BORDER!” Trump said in one tweet.

In another, he suggested that the “onslaught” of immigrants could undermine a recently announced reworked trade deal with Mexico and Canada, writing that immigration is “far more important to me, as President, than Trade.”

The new deal, which replaces the North American Free Trade Agreement, has yet to be signed by the three countries. Congress is not expected to ratify it before next year.

Trump’s comments come as he has been urging fellow Republicans to make immigration a central issue in the closing weeks of their midterm election campaigns and blaming Democrats for his inability to pass immigration legislation in the GOP-controlled Congress.

“All Democrats fault for weak laws!” Trump said in one tweet Thursday.

Secretary of State Mike Pompeo is scheduled to meet with departing Mexican President Enrique Pena Nieto on Friday.

Trump has made migrant caravans a symbol of all that is wrong with U.S. immigration policies. In his tweets Thursday, he warned that the latest group includes “MANY CRIMINALS.”

Earlier this year, Trump’s criticism turned a migrant caravan into a spectacle, with day-by-day media coverage of the journey. That episode caused a spat between the United States and Mexico and was used to justify a deployment of National Guard troops to the border.

When Trump has previously mobilized troops in response to unlawful migration, their missions have been mostly passive support for border agents, such as logistics and surveillance.

The Posse Comitatus Act forbids using the military for civilian law enforcement duties outside military bases in the United States.

Mexican officials said Hondurans would not be allowed to enter as a group and would either have to show a passport and visa — something few have — or apply individually for refugee status, a process that can mean waiting for up to 90 days for approval. They also said migrants caught without papers would be deported

The group has swollen in size since leaving San Pedro Sula, one of the world’s most dangerous cities, on Friday. By some estimates, it now contains more than 3,000 people.

Trump also threatened in April to withdraw aid from Honduras and other countries that allowed passage for a similar caravan that originated in the Central American country. That caravan dissipated as it approached the U.S. border.

Nearly four months after a federal judge ordered the Trump administration to reunite families separated at the border, 245 children remain in government custody, according to a new analysis of government data released this week by the American Civil Liberties Union.

The parents of 175 of the children have been deported, the report says, and 125 of them have decided to remain in the United States and pursue asylum on their own.

The ACLU sued the federal government over the separations, leading to an order from U.S. District Judge Dana Sabraw to reunite 2,654 children — including 103 aged four and younger — with their parents as soon as possible.

The Justice Department did not immediately respond to a request for comment.

Associated Press contributed.