Soldiers board a bus at the Harlingen, Tex., airport for deployment at the border. (Senior Airman Alexandra Minor/Handout/EPA-EFE/REX/Shutterstock)

Jon D. Michaels, a law professor at the UCLA School of Law, is the author of “Constitutional Coup: Privatization’s Threat to the American Republic.” Jeffrey H. Smith, a retired partner at Arnold & Porter and former Army judge advocate general officer, has served as general counsel of the CIA and the Senate Armed Services Committee.

President Trump has ordered 5,200 U.S. troops to the southern border and says he may send as many as 15,000. That’s approaching the number now serving in Afghanistan and Iraq, and more than Gen. John J. Pershing mustered to pursue Mexican revolutionary Pancho Villa in 1916.

The troops’ mission appears to be to block two caravans of between 3,600 and 7,000 Central Americans, most of whom are fleeing violence and poverty, from entering the country.

Defense Secretary Jim Mattis on Wednesday, responding to a reporter’s question, said that the Pentagon doesn’t “do stunts.” But given the president’s race-baiting and fearmongering on the eve of deeply consequential midterm elections, the stunt-like quality of this exercise is hard to miss.

Let’s start with the basics. First, there is no credible basis for the president’s assertion that the migrants are dangerous. They are hundreds of miles away from the U.S. border and are the very definition of Emma Lazarus’s tired, poor and huddled masses. They should not be blocked by bayonets but met by a joint U.S.-Mexico operation that provides humanitarian support and processes them for possible admission to the United States in accordance with immigration and asylum laws.

Second, even if any of the migrants prove to be dangerous or cross the border illegally, it does not follow that this is a job for the U.S. military. Federal law-enforcement agencies — for instance, the Border Patrol — are surely up to the task. But more to the point, the Posse Comitatus Act of 1878 prohibits the use of military personnel to enforce U.S. laws on American soil. To bypass Posse Comitatus, the Trump administration must establish that the migrants are a threat to national security. If the administration succeeds, it will set a precedent for the use of military force domestically to combat organized crime syndicates, street gangs or, perhaps, white supremacist groups — all of which strike us as more violent and more threatening to national security and the rule of law. But combating them, too, is a matter for the police and prosecutors, not the military.

Third, Trump is risking the politicization of the armed forces. Enforcement of U.S. immigration laws is important, and no responsible person advocates open borders. But the president appears to have cynically chosen to exploit irrational fear of nonwhite immigrants for political ends, using the military in the service of that goal. Given the country’s increasing divisions over immigration policy, Trump is endangering the trust and respect the U.S. military enjoys. Keeping troops out of the immigration fight would help ensure that the military remains welcoming to all those who wish to serve, regardless of their political views or the color of their skin.

These deployments will likely alienate many inside and outside the military. Members of the public who oppose the president’s actions may consider the military complicit in a gratuitously cruel and economically unsound policy. Some of the troops, including senior officers, may feel the same way, particularly if ordered to seize, detain and separate children from their parents. Leaving the service could become a form of protest, just as it appears to have been for many career civil servants — in such agencies as the State Department, the Environmental Protection Agency and the Justice Department — who have quit government during the Trump administration in unusual numbers.

So far, little is known about the military’s plan. The initial deployment will include engineering, aviation, military police, logistics and, predictably, “media” units. There may be some justification for a modest deployment, but what exactly is the mission? On Thursday, the president said that if any of the migrants throw rocks at troops, the soldiers will consider it the use of “a firearm.” On Friday, following much criticism for implying that rock-throwers would be shot, Trump said they would be arrested. The Pentagon must wonder: What will the commander in chief say the rules of engagement are on Monday?

At a minimum, the Pentagon owes the country an explanation. Congress has a constitutional duty to oversee the armed forces and to ensure that they are properly and lawfully utilized. As such, Congress must press the defense secretary to ascertain the national security threat posed by the caravans, the troops’ mission and how that mission squares with the Posse Comitatus Act. Absent such an accounting, the inescapable conclusion will be that the military deployment to the border is a shameless, and dangerous, stunt.