President Trump unexpectedly fired FBI Director James Comey on Tuesday after a finding by the Justice Department that he mishandled the investigation into Hillary Clinton's emails last year.

Trump said he acted based on the recommendations of Attorney General Jeff Sessions and Deputy Attorney General Rod Rosenstein, who found that Comey improperly moved to "usurp" the attorney general's authority and decided not to prosecute Clinton.

"I have received the attached letters from the attorney general and deputy attorney general of the United States recommending your dismissal as the director of the Federal Bureau of Investigation," Trump said in a letter to Comey. "I have accepted their recommendation and you are hereby terminated and removed from office, effective immediately."

"While I greatly appreciate you informing me, on three separate occasions, that I am not under investigation, I nevertheless concur with the judgment of the Department of Justice that you are not able to effectively lead the bureau," Trump said. "It is essential that we find new leadership for the FBI that restores public trust and confidence in its vital law enforcement mission. I wish you the best of luck in your future endeavors."

The Trump administration will immediately begin a search for Comey's successor. FBI Deputy Director Andrew McCabe has been floated as a possible replacement, according to Fox News.

"The FBI is one of our nation's most cherished and respected institutions and today will mark a new beginning for our crown jewel of law enforcement," Trump said in a White House statement.

In a memo explaining to Trump why he thought Comey should be fired, Rosenstein, who was sworn into office in late April, pointed to the FBI director's July press conference explaining why Democratic presidential candidate Hillary Clinton should not be prosecuted over her use of a private email server while secretary of state.

"The director was wrong to usurp the attorney general's authority on July 5, 2016, and announce his conclusion that the case should be closed without prosecution. It is not the function of the director to make such an announcement. At most, the director should have said the FBI had completed its investigation and presented its findings to federal prosecutors," Rosenstein wrote.

Comey's involvement in the 2016 general election didn't end there. On Oct. 28, just days before voters went to the polls, Comey sent a letter to Congress saying new emails had surfaced related to the investigation into whether Clinton had mishandled classified information.

Just over a week later, Comey said they had found no new wrongdoing by Clinton, but the candidate's staff has argued the Oct. 28 letter significantly hurt her campaign.

Days after Trump's inauguration in January, Trump memorably shook Comey's hand while meeting at the White House.

Comey's firing comes the same day the FBI had to correct testimony before a Senate panel that former Clinton aide Huma Abedin "forwarded hundreds and thousands" of possibly sensitive emails to her husband, former Democratic Rep. Anthony Weiner.

The FBI on Tuesday said the majority of the data that was transferred "occurred as a result of backup of personal data electronic devices, with a small number of result of manual forwarding by Ms. Abedin to Mr. Weiner."

Those emails, the subject of the Oct. 28 letter, were found during an unrelated investigation into Weiner.

Sessions recused himself from a Justice Department investigation into allegations that Russia colluded with the Trump administration during the election. Rosenstein is overseeing that probe. Comey was overseeing the FBI's probe into any Trump connections with Russia.

Democrats reacted with alarm to the announcement.

"Congress needs to have immediate emergency hearings to obtain testimony directly from Attorney General Sessions, the deputy attorney general, and FBI Director Comey," Democratic Rep. Elijah Cummings, the ranking member of the House Committee on Oversight and Government Reform, said in a statement.

"The White House was already covering up for Michael Flynn by refusing to provide a single document to Congress, and now the president fired the one independent person who was doing the most to investigate President Trump and his campaign over allegations of coordination with Russia," Cummings wrote. "It is mindboggling that the attorney general — who claimed to have recused himself — was directly involved in the decision to fire Director Comey according to the White House itself."