
Mr Trump announced the news in a tweet, saying Christopher Miller, the director of the National Counterterrorism Center, will serve as acting secretary "effective immediately".
The move could be seen as unsettling for the Pentagon and a source of concern for worldwide allies and partners.
Mr Esper, Mr Trump's fourth Pentagon chief in four years, was sacked after 16 months in the job trying to keep his head down politically as he pursued fundamental reforms to the massive Pentagon bureaucracy and sought to reshape the USA defense posture worldwide to focus on the threat of China. The fact that he dismissed Esper even after losing the election, however, was not a given.
Mr Trump has so far not conceded the USA election to President-elect Joe Biden, and has vowed to challenge the projected result in court. Several thousand political appointees across the government will see their jobs end by that date.
President Trump has fired a significant number of his officials and advisers during his tenure, often using Twitter to announce the dismissal. Esper publicly opposed Trump's threats to invoke the two-centuries-old Insurrection Act, which would allow the president to use active-duty troops in a law enforcement role.
Michael O'Hanlon at the Brookings Institute think-tank said he did not believe Trump was likely to embark on a damaging shakeup of USA national security policy despite firing Esper. Jim Mattis as his first Defense secretary and John Kelly as his first secretary of Homeland Security.
Officials familiar with internal discussions say Mr Esper had been ready to resign for months. "Mark "Yesper"? Did you call him 'Yesper?'" Trump said, in what appeared to be an allusion to suggestions that Esper was a yes man for the president.
Mr Esper was among those administration officials in 2019 who urged the President to release aid to Ukraine that Mr Trump blocked as he pressured the country's President for investigations into Mr Biden's son, Hunter Biden, and Ukraine's alleged support for Hillary Clinton in the 2016 election. "At some point, that's what happens".