President Trump may be rattling our nerves with his baseless claims of fraud and his vindictive firings. But the two weeks since the election should give Americans greater confidence that our democracy can’t so easily be subverted.

Trump on Tuesday evening launched yet another assault on members of his administration who have dared to speak up. In a tweet, he “terminated” Christopher Krebs as head of the Cybersecurity and Infrastructure Security Agency at the Department of Homeland Security. Krebs’s supposed crime was that he had rebutted Trump’s wild accusations of “massive improprieties and fraud” in the Nov. 3 election, as the president put it in the tweet firing Krebs.

When the history books about this election are written, Krebs will be one of the heroes. Last Thursday, when Trump was trying to spin his unsubstantiated claim that Dominion Voting Systems and other companies that provided election software had diverted votes to President-elect Joe Biden, Krebs delivered an emphatic rebuttal on behalf of his agency and the 50 state election monitors he had worked with.

“There is no evidence that any voting system deleted or lost votes, changed votes, or was in any way compromised,” said a statement issued by CISA. That was the latest of a series of warnings before and after the election that Krebs posted as part of his regular “Rumor Control” warnings about malicious election claims.

Krebs had even retweeted a caution against “wild and baseless claims about voting machines, even if they’re made by the president.” That may have infuriated the White House, but he spoke for a task force that included representatives of secretaries of state and state election directors in all 50 states — the people who administered the election.

Biden has sensibly taken a low-key approach to Trump’s post-election sulks and tantrums. Such behavior is an embarrassment to the country, as Biden said Monday, but it won’t stop the transition of power on Jan. 20. Biden should keep repeating this message: The departing president can demean himself and his party, but he can’t change the result.

And as Trump’s lawsuits collapse, one by one, the Nov. 3 outcome is being ratified — and reinforced — by the courts. If Trump tries to circumvent these legal judgments and take extralegal action (in other countries, we’d call it a “coup”), there are guardrails in place.

Krebs and other election security officials had months to prepare, because Trump has been so blatant about his intention to subvert a result that doesn’t go his way. Back in July, the president refused to commit to accepting the outcome and, during the campaign, he made almost daily claims about the coming fraud. After losing by substantial margins in both the popular vote and electoral college, Trump knew he needed to allege a conspiracy that involved millions of votes. And so he has.

Trump’s prime target was Dominion Voting Systems. Last Thursday, the president retweeted a baseless allegation that the company had deleted 2.7 million votes. The company immediately issued a “categorical” denial, but Trump doubled down on Saturday with a claim that Dominion was “a privately owned Radical Left company.”

The charge was amplified by pro-Trump lawyer Sidney Powell, who argued bizarrely on Sunday that CIA Director Gina Haspel “should be fired immediately” because Haspel had disregarded claims about Dominion. Powell said evidence of fraud was “coming through a fire hose.”

As these conspiracy theories rise like swamp gas, is the nation helpless? Thankfully not, because of monitoring systems put in place months ago by officials determined to protect our democracy.

With Trump’s lawsuits falling short, some people fear he will turn to the military to resist a lawful transfer of power. The anxiety increased last week when Trump sacked Defense Secretary Mark T. Esper and his top aides and replaced them with what looked like a war cabinet. But here again, there are protections in place.

The chief guardian of the military’s integrity is Gen. Mark A. Milley, the barrel-chested chairman of the Joint Chiefs of Staff. He promised Congress in August that the military would play “no role” in post-election disputes. If anyone missed the message, Milley told his troops on Veterans Day: “We are unique among militaries. We do not take an oath to a king, or a queen, a tyrant or a dictator. We do not take an oath to an individual. . . . We take an oath to the Constitution.”

The president is the commander in chief, but the Pentagon operates under the rule of law. Robert S. Taylor, a former Defense Department general counsel, has cautioned officials that they could face legal risks if they try to interfere in the 2020 outcome. And Eugene R. Fidell, a military law expert at Yale, has created an “Orders Project” to advise soldiers who think they may have received illegal or improper commands.

Trump has the power to fire people, but not to rewrite history. During his remaining weeks in office, he will try to frazzle nerves and take every opportunity to counterpunch. But this reality show has been canceled — by the American public and the officials who protected the integrity of their votes.

Read more: