President Donald Trump has fired FBI Director James Comey.

In a statement, Trump says Comey's firing "will mark a new beginning" for the Federal Bureau of Investigation.

The White House says the search for a new FBI director will begin immediately.

Comey's firing comes days after he testified on Capitol Hill about the FBI's investigation into Russia's election meddling and possible connections between Russia and Trump's campaign.

A former top Justice Department official whose criticism of Comey was used to support his ouster is calling the justification "a sham."

Trump said he based Comey's firing on a memo by Deputy Attorney General Rod Rosenstein that slammed Comey's handling of the Hillary Clinton email probe. Rosenstein cited former Deputy Attorney General Donald Ayer as saying he agreed it was inappropriate.

Ayer told The Associated Press he thinks the explanation for Comey's firing is a "sham."

Trump had supported "the most incorrect things that Comey did," such as speaking out about the closed probe and announcing it was being reopened just days before the election.

Ayer says Rosenstein "should realize that his correct assessment of those mistakes is now being used to justify firing for a very different reason."

Aides to Trump are defending his decision, saying it was needed to restore confidence in the agency, not about any ongoing investigations.

Counsel to the president Kellyanne Conway says in an interview with CNN, "It's not a cover-up," and says it "had nothing to do with Russia."

Conway says Trump took the recommendation of the attorney general's office that it was time for "fresh leadership." She adds, "This is what leaders do. They take decisive action."

White House spokeswoman Sarah Huckabee Sanders says in an interview with Fox that Comey had lost the confidence of rank-and-file members of the FBI and members of Congress.