“He feels it’s a national security problem,” Mr. Trump added. “I do, too.”

In a joint statement, two Utah Republicans, Senators Mitt Romney and Mike Lee, agreed that border protections needed to be strengthened, but said that Congress had ceded power to the executive branch and needed to pass legislation defending its ability to set spending.

“Funding the border wall is an important priority, and the executive branch should use the appropriate channels in Congress, rather than divert already appropriated funding away from military construction projects and therefore undermining military readiness,” Mr. Romney said.

Democrats were more scathing in their objections. A group from the Senate Appropriations Committee, in its own joint statement, recalled that “the president promised Mexico would pay for his wall, not the military and their families.”

“This is a subversion of the will of the American people and their representatives,” said Representative Steny H. Hoyer of Maryland, the majority leader. “It is an attack on our military and its effectiveness to keep Americans safe.”

The timing of the cuts is likely to intensify the looming debate over how to fund the government and set defense policy, and the Democratic majority in the House and the Republican majority in the Senate will most likely be at odds over whether to replace the funds diverted to the border.

Privately, several Pentagon officials acknowledged that their position was tenuous, since Congress would ultimately have to agree to replace the funds. If Congress does not agree to do that, the projects will be effectively canceled.

Once Congress returns on Monday from its August recess, the Senate and the House will have to reconcile their versions of the National Defense Authorization Act, the annual defense policy bill. While the Senate agreed to replace the funds that were expected to be removed from military construction, the House refused to do so and included an additional provision that would bar the administration from trying to reallocate funds in the next fiscal year.