A week before the midterm elections, the president of the United States announced he would deploy up to 15,000 active duty military troops to the United States-Mexico border to confront a menacing caravan of refugees and asylum seekers. The soldiers would use force, if necessary, to prevent such an “invasion” of the United States.

Mr. Trump’s announcement and the deployment that followed (of roughly 5,900) were probably perfectly legal. But we are a bipartisan threesome with decades of experience in and with the Pentagon, and to us, this act creates a dangerous precedent. We fear this was lost in the public hand-wringing over the decision, so let us be clear: The president used America’s military forces not against any real threat but as toy soldiers, with the intent of manipulating a domestic midterm election outcome, an unprecedented use of the military by a sitting president.

The public debate focused on secondary issues. Is there truly a threat to American security from an unarmed group of tired refugees and asylum seekers on foot and a thousand miles from the border? Even the Army’s internal assessment did not find this a very credible threat.

Can the president deny in advance what could be legitimate claims for asylum, without scrutiny? Most likely, this violates treaty commitments the United States made as part of its agreement to refugee conventions in 1967, which it has followed for decades.