After Trump lost the 2020 presidential election to Joe Biden, Trump launched a months-long effort to challenge the election outcome and remain in power, claiming that the election had been "stolen" from him.[284] In his subsequent memoir, published in 2022, Esper wrote that Trump's effort "was a national embarrassment that undermined our democracy, our credibility, and our leadership on the world stage."[284]
On November 9, 2020, days after his election loss, Trump tweeted that Esper was "terminated," and that he had been replaced by Christopher C. Miller, the director of the National Counterterrorism Center who would serve as Acting Secretary of Defense.[285] Esper had written his resignation letter four days earlier, when a winner had not yet been determined.[286]
On January 2, 2021, days before the end of Trump's term and the inauguration of Biden, Esper, along with all other living former secretaries of defense, published a Washington Post op-ed piece in January 2021 that rebuked Trump's effort to alter the election results, and said there was no role for the military to change them. The group's piece appeared days after Trump ally Michael Flynn, an ex-Army general, and reportedly Trump himself, discussed the possibility of declaring martial law and attempting to stay in power. The group wrote: "Our elections have occurred. Recounts and audits have been conducted. Appropriate challenges have been addressed by the courts. Governors have certified the results. And the electoral college has voted. The time for questioning the results has passed; the time for the formal counting of the electoral college votes, as prescribed in the Constitution and statute, has arrived."[287] Esper later wrote that Trump's behavior on January 6, when a mob of his supporters, incited by the president, attacked the Capitol and disrupted the counting of the electoral votes, "threatens our democracy."[288]