President Trump on Tuesday fired a top Department of Homeland Security official who led the agency’s efforts to help secure the election and was vocal about tamping down unfounded claims of ballot fraud.

In a tweet, Trump fired Christopher Krebs, who headed the Cybersecurity and Infrastructure Security Agency (CISA) at DHS and led successful efforts to help state and local election offices protect their systems and to rebut misinformation.

Earlier Tuesday, Krebs in a tweet refuted allegations that election systems were manipulated, saying that “59 election security experts all agree, ‘in every case of which we are aware, these claims either have been unsubstantiated or are technically incoherent.’ ”

Krebs’s statement amounted to a debunking of Trump’s central claim that the November election was stolen.

Trump, who has not conceded the election to President-elect Joe Biden, said on Twitter: “The recent statement by Chris Krebs on the security of the 2020 Election was highly inaccurate, in that there were massive improprieties and fraud — including dead people voting, Poll Watchers not allowed into polling locations, ‘glitches’ in the voting machines which changed votes from Trump to Biden, late voting, and many more. Therefore, effective immediately, Chris Krebs has been terminated as Director of the Cybersecurity and Infrastructure Security Agency.”

Late Tuesday, following Trump’s tweet, acting DHS secretary Chad Wolf called Krebs’s deputy, Matthew Travis, to inform him that the White House had overruled CISA’s succession plan that named him acting director, essentially forcing him to resign, Travis said.

DHS spokesman Alexei Woltornist said the White House had not asked him to resign.

Trump and his allies have offered no proof for his fraud allegations and the president’s claims were quickly flagged by Twitter as “disputed.”

Krebs’s dismissal was not unexpected, as he told associates last week that he was expecting to be fired. His latest tweet about the security of the election, which followed similar earlier assessments by his agency, including on its Rumor Control Web page, angered the president, according to an official who spoke on the condition of anonymity to discuss a sensitive matter.

In recent weeks Trump has made repeated, unproved charges of voter and ballot fraud, and his campaign is challenging election results in several states — so far with little success.

Krebs’s agency has asserted its independence in recent days, on Thursday issuing a statement that contradicted Trump’s allegations of fraud.

“The November 3rd election was the most secure in American history,” said the statement from the coordinating council of state and local federal government entities in charge of protecting elections. “There is no evidence that any voting system deleted or lost votes, changed votes, or was in any way compromised.”

After his firing, Krebs responded from his personal Twitter account: “Honored to serve. We did it right. Defend Today, Secure Tomorrow. #Protect2020.”

Krebs worked closely with former DHS secretary Kirstjen Nielsen, who resigned in April 2019 after clashing with Trump over election security and immigration. His association with Nielsen also factored into the decision to dismiss Krebs, a DHS official said.

The news disturbed many current and former officials and cybersecurity professionals who said that under Krebs, DHS significantly boosted the agency’s capabilities to help the private sector, as well as those managing election infrastructure, better defending themselves against foreign and domestic threats.

“This is outrageous but not surprising — @realDonald­Trump has made a habit of firing those who are highly competent, have integrity and courage, and stand up for the #RuleOfLaw,” said John Mitnick, a former DHS general counsel who was fired last year during one of several DHS shake-ups under Trump.

Thomas Bossert, a former top White House cybersecurity official who was forced out in 2018, decried the move. “If the grounds of removal were insubordination, it’s a very twisted rationale,” he said. “Insubordinate to the president or insubordinate to the Constitution? I think Krebs had no choice.”

Krebs has said he was determined to improve the security of state and local election systems before the 2018 elections. He called the midterms the “exhibition game,” with 2020 being “the big game.”

CISA, along with other federal agencies, greatly ramped up coordination with social media companies and state and local officials in advance of the 2020 election.

Krebs joined DHS in March 2017 as a senior counselor to then-Secretary John Kelly. In June 2018, he was confirmed as undersecretary for the National Protection and Programs Directorate, which was rebranded as CISA in November 2018.

His removal followed the firing of two other senior DHS officials — a CISA assistant director, Bryan Ware, and the top official for international affairs, Valerie Boyd. The White House appears to be removing anyone deemed disloyal, according to three people familiar with the situation.

Ware on Tuesday said of Krebs: “He was able to create a voice that made so many of these election security and foreign interference things and disinformation campaigns more accessible to a broader audience than ever before. It is a shame to see anyone who works so hard and commits everything to this job fired over Twitter.”

With Krebs and Travis gone, the line of succession falls to CISA Executive Director Brandon Wales, who is a career senior executive service employee.

Josh Dawsey and Joseph Marks contributed to this report.