But the idea that Mr. Spicer called inconceivable a year ago is back in play.

On Wednesday, White House officials said that President Trump planned to mobilize the National Guard to the southern border. The announcement came a day after Mr. Trump surprised some of his top advisers by saying that he wanted to send in the military to do what the immigration authorities, in his view, could not: secure the border from what he characterized as a growing threat of unauthorized immigrants, drugs and crime from Central America.

Kirstjen Nielsen, the homeland security secretary, said on Wednesday that her department and the Defense Department would work with governors to deploy the Guard to “assist the Border Patrol.” But beyond that, officials had few details about how many troops would go, when they would arrive or in what capacity they would serve.

Ms. Nielsen said she hoped the deployment would begin “immediately,” but administration officials said the formal agreements with governors that would allow the troops to mobilize were still being negotiated.

At the Pentagon, several officials privately expressed concern about being seen as picking a fight with an ally at a time when the military has plenty of adversaries — the Islamic State, North Korea, Russia, Syria — to contend with. Massing American troops at another country’s border, several current and former Defense Department officials said, would send a message of hostility and raise the chances of provoking an all-out conflict.

“We are so lucky here in this country when you look at our borders,” said Maj. Gen. Paul Eaton, a retired veteran of the Iraq war. “We’ve got the Pacific on one side, the Atlantic on the other and allies to the north and the south. Mexico is not an adversary. Why would you present this offensive barrier to a friendly country?”