For a Pentagon that thrives on orderly transition, President Donald Trump’s sudden firing of Defense Secretary Mark Esper was a slap in the face. It stunned the military leadership at a time when they were craving stability.

Trump’s “termination” of Esper by tweet just after noon on Monday blindsided the secretary, who according to close associates thought that he had “turned a corner” with Trump and would remain in his job until the inauguration. It also surprised Gen. Mark Milley, the chairman of the Joint Chiefs of Staff, who was lunching with senior Pentagon officials when the news broke, according to a senior military official.

Pentagon officials were similarly stunned by Trump’s choice of Christopher Miller, director of the National Counterterrorism Center, as acting defense secretary. Miller is an unknown to many senior officials, who were waiting Monday to meet with him and get some inkling of the guidance that he has received from the White House. But, as of early Monday night, none had been given, a senior military official said.

The mystery is whether the Esper firing is simply an act of pique and petulance by a president who is fuming about having lost his reelection bid, or whether this 11th-hour reshuffle has a deeper and potentially more dangerous purpose. Either way, a half-dozen Pentagon veterans described it as a sign of Trump’s disrespect for the military as his power ebbs.

Robert Gates, who served as secretary of defense under Presidents George W. Bush and Barack Obama, argued that it was “pretty reckless” for Trump to dump his Pentagon leadership during a post-election transition of power – a time when adversaries can take advantage of any American weakness or disorientation. Gates said he was concerned about “not having an experienced and steady hand that the military knows.”

Another top former Pentagon official, a Republican, contended that Trump’s move was “just spite,” and that it would have no effect on operations. “We shouldn’t worry about it,” he said. “The troops will stand watch, and in the short term there will be no operational effect at all.” The military command structure is organized precisely to prevent sudden personnel changes from diminishing the military’s readiness or operations, several current and former officials argued.

In the sudden confusion of Monday’s announcement, some Pentagon officials worried that Trump might have a broader aim. Several speculated that the president might want to accelerate the withdrawal of U.S. troops from Afghanistan and Iraq to buff his legacy – even though that move would be against strong military advice for a careful withdrawal that reduces U.S. forces from the current 4,500 in Afghanistan and about 3,000 in Iraq only if conditions and U.S. security interests warrant such a move.

Any sudden drawdown in Afghanistan or Iraq would be complicated by the logistics of moving U.S. equipment and supplies out of those countries. Troops can be loaded onto airplanes, but not ground vehicles, helicopters or the other implements of the United States’ vast deployment of power. That’s even more true with U.S. forces in Europe, Japan and South Korea, which Trump thunders about withdrawing from, but whose presence involves housing for families, schools for children and other immovables.

A darker possibility is that Trump wants a Pentagon chief who can order the military to take steps that might help keep him in power because of an election result that he baselessly claims is fraudulent. Any such attempt would be strongly resisted by Milley and his senior commanders, as well as the civilian service chiefs. But the fact remains that until his term expires on Jan. 20, Trump remains the commander in chief, whose orders must be obeyed if they’re lawful.

“My belief is that the chain of command will try to keep things steady as they go,” said retired Gen. Joseph Votel, the widely respected former head of Central Command in the Middle East and Special Operations command.

Esper is an unlikely victim of Trump’s wrath. His loyalty to Trump was so strong that it initially worried some military leaders, who feared that their boss wouldn’t stand up to the White House. Esper’s choke point came in June, when he opposed Trump’s effort to use the Insurrection Act to deploy active-duty U.S. troops to quell the racial justice protests spreading across America.

Esper accompanied Trump on his now-notorious walk across Lafayette Square, Bible in hand, after protesters had been tear-gassed. But Esper regretted it and said publicly and privately that his loyalty was to the Constitution, not the president. That, for Trump, was unforgivable. “Esper has known since June that he hung by a thread,” said Gates, who has remained in contact with him.

Several top Republican senators tried to talk Trump out of the destabilizing move without success, one Pentagon source said.

What troubles military commanders is a fear that Trump, not for the first time, is putting his personal interests ahead of those of the nation. Speaking of Miller and the team he will assemble for these final days, one senior military officer asked: “Will they be willing to disregard facts, to do whatever the president thinks?”

It’s appalling that this question even needs to be asked.

Contact David Ignatius on Twitter @IgnatiusPost