President Trump on Friday said that he was considering the declaration of a “national emergency” along the border with Mexico, which he apparently believes would allow him to divert funds from the military budget to pay for a wall, and to use military personnel to build it.

While it is hard to know exactly what the president has in mind, or whether he has any conception about what it would entail, one thing is clear: Not only would such an action be illegal, but if members of the armed forces obeyed his command, they would be committing a federal crime.

Begin with the basics. From the founding onward, the American constitutional tradition has profoundly opposed the president’s use of the military to enforce domestic law. A key provision, rooted in an 1878 statute and added to the law in 1956, declares that whoever “willfully uses any part of the Army or the Air Force” to execute a law domestically “shall be fined under this title or imprisoned not more than two years” — except when “expressly authorized by the Constitution or Act of Congress.”

Another provision, grounded in a statute from 1807 and added to the law in 1981, requires the secretary of defense to “ensure that any activity (including the provision of any equipment or facility or the assignment or detail of any personnel)” must “not include or permit direct participation by a member of the Army, Navy, Air Force, or Marine Corps in a search, seizure, arrest, or other similar activity unless participation in such activity by such member is otherwise authorized by law.”