Trump says he's fired Defense Secretary Mark Esper

"Mark Esper has been terminated," Trump tweeted.

"I am pleased to announce that Christopher C. Miller, the highly respected Director of the National Counterterrorism Center (unanimously confirmed by the Senate), will be Acting Secretary of Defense, effective immediately.....Chris will do a GREAT job! Mark Esper has been terminated. I would like to thank him for his service," Trump tweeted.

The move comes two days after Trump lost reelection and when he was expected to purge top members of his administration with whom he had long been unhappy.

Trump was particularly displeased that Esper had opposed using active-duty military under the Insurrection Act to deal with the George Floyd protests in June, as the president had threatened to order.

Pentagon officials were scrambling to react to the president's tweet.

According to a U.S. official, Esper had a resignation letter ready and that Esper was strongly considering resigning ahead of a possible firing.

According to a defense official, Mark Meadows, the White House chief of staff, called Esper to warn him that Trump’s tweet firing him was coming, but the official did not know how much in advance Meadows called Esper.

House Speaker Nancy Pelosi didn't mince words in a statement issued shortly afterward.

"The abrupt firing of Secretary Esper is disturbing evidence that President Trump is intent on using his final days in office to sow chaos in our American Democracy and around the world," she said. "Continuity and stability are always important during a presidential transition; they are absolutely imperative at this moment, as this historically erratic Administration prepares for its departure.

"It is concerning that reports show that this firing was an act of retribution by the President, allegedly for Secretary Esper’s refusal to send active-duty military troops to crack down on peaceful demonstrations against police brutality. Most disturbingly, however, the timing of this dismissal raises serious questions about Trump’s planned actions for the final days of his Administration," her statement continued.

"Again and again, Trump’s recklessness endangers our national security. It is disturbing and dangerous that, at this precarious moment, our military will now be led by an official who has not been confirmed for this position by the Senate," Pelosi said.

Miller arrived at the Pentagon exactly one hour after the president tweeted that Esper had been fired.

According to a senior defense official, Miller’s guidance to senior staff was to continue the DOD’s mission with no significant changes at this time. The official stressed that the chain of command within the Department of Defense was never broken because it all happened immediately.

Also Monday afternoon, Gen. Mark Milley, the chairman of the Joint Chiefs of Staff, and the combatant commanders spoke via secure videoconference about the transition at the Pentagon.

Miller was getting a series of briefings on all matters relating to being the acting secretary of defense, including about the nuclear codes and current operations around the world, the defense official said.

ABC News' John Parkinson contributed to this report.

This report was featured in the Tuesday, Nov. 10, 2020, episode of “Start Here,” ABC News’ daily news podcast.

"Start Here" offers a straightforward look at the day's top stories in 20 minutes. Listen for free every weekday on Apple Podcasts, Google Podcasts, Spotify, the ABC News app or wherever you get your podcasts.