President Donald Trump fired FBI Director James Comey on Tuesday after senior Justice Department officials concluded that he'd mishandled the investigation of Hillary Clinton's use of a private email server while she was secretary of state.

"You are hereby terminated and removed from office, effective immediately," Trump told Comey in a personally signed letter obtained by NBC News.

The FBI has been investigating allegations that people involved with Trump's presidential campaign had undisclosed ties to Russia.

But during a brief meeting with NBC News in the Oval Office on Tuesday evening, Trump said the Russia probe wasn't a factor in his decision.

Trump said that while he'd had concerns about Comey for some time, it was the FBI's "clarification" of Comey's inaccurate Senate testimony last week about Hillary Clinton's use of a private email server that raised new questions about the director's competence and judgment.

In his letter to Comey, the president wrote: "While I greatly appreciate your informing me, on three 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."

Deputy White House Press Secretary Sarah Huckabee Sanders told reporters Tuesday night that Comey's inaccurate Senate testimony last week "showed that he was incapable of continuing to do his job."

"Here's the bottom line: Comey had lost the confidence across the board, from House members, from Senate members, from rank-and-file members of the FBI and the American public," Sanders said.

Republicans and Democrats alike said the dismissal called the FBI's independence into question, and many Democrats immediately called for appointment of an independent counsel to take over the investigation.

Related: Democrats Charge Comey Firing Nixonian, Demand Special Prosecutor

"Everyone will suspect [a] coverup" otherwise, Senate Democratic leader Chuck Schumer of New York said at a hastily called news conference, adding:

"Given the way the president fired Director Comey, any person appointed to replace him should be concerned that he or she will suffer the same fate if they run afoul of the Trump administration."

Schumer said he'd personally told Trump: "I think you've made a mistake."

White House Press Secretary Sean Spicer said in a statement that Trump acted "on the clear recommendations of both Deputy Attorney General Rod Rosenstein and Attorney General Jeff Sessions."

He said a search for a new FBI director will begin "immediately."

Meanwhile, Deputy Director Andy McCabe will take over temporarily as acting director, Sessions told FBI employees in a message obtained by NBC 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," the statement quoted Trump as saying.

Related: Timeline: Former FBI Director James Comey's Fall From Grace

Federal officials told NBC News that Comey was in the FBI's Los Angeles operations center when he got a call notifying him that he had been fired. Employees in the office, aware of the news reports, gathered outside the center and gave him an ovation as he came out.

He thanked them for their service, according to those who were there, and said that working with the FBI was the highest honor of his life.

The FBI said in a letter to the Senate Judiciary Committee on Tuesday that Comey grossly overstated the number of emails that Clinton aide Huma Abedin forwarded to husband, Anthony Weiner, while working at the State Department.

The White House said the dismissal had already been in the works before the FBI acknowledged Comey's inaccurate testimony. But three senior FBI and Justice Department officials told NBC News that Comey was given no warning in advance.

In his recommendation to Trump, also obtained by NBC News, Rosenstein wrote that Comey mishandled the overall investigation of the email scandal and said he was wrong to have announced last July that the Justice Department's investigation of Clinton's emails was being closed.

Referring to Comey's statement on Oct. 28 that more Clinton emails had been found on Weiner's laptop computer, Rosenstein wrote: "We do not hold press conferences to release derogatory information about the subject of a declined criminal investigation."

"The FBI Director is never empowered to supplant federal prosecutors and assume command of the Justice Department," he wrote. "The way the Director handled the conclusion of the email investigation was wrong."

Sen. Chuck Grassley, R-Iowa, chairman of the Judiciary Committee, said in a statement that "the handling of the Clinton email investigation is a clear example of how Comey's decisions have called into question the trust and political independence of the FBI."

"The effectiveness of the FBI depends upon the public trust and confidence," he said. "Unfortunately, this has clearly been lost."

Sen. Patrick Leahy of Vermont, a Democrat on the committee, called the move "shocking."

"No one should accept President Trump's absurd justification that he is now concerned that FBI Director Comey treated Secretary Clinton unfairly," Leahy said in a statement.

"The President has removed the sitting FBI Director in the midst of one of the most critical national security investigations in the history of our country — one that implicates senior officials in the Trump campaign and administration," he said. "This is nothing less than Nixonian."

Representatives of Clinton and former President Barack Obama said they had no immediate comment. But other Democrats calling for an independent investigation of the Trump campaign's alleged Russia ties included Sens. Kirsten Gillibrand of New York, Bill Nelson of Florida and Jeff Merkley of Oregon.

Robby Mook, Clinton's campaign manager, said on Twitter that even though he was "disappointed and frustrated" by the email investigation, Comey's dismissal "terrifies me."

The president does have the legal authority to fire the FBI director, who is appointed for a 10-year term that spans presidential administrations. The Senate must confirm his replacement.

The director typically isn't removed without cause, and no director was fired until 1993, when President Bill Clinton dismissed William Sessions after an internal watchdog found that he had improperly billed the FBI for personal spending.

While "I regret that that took place," Sen. John McCain, R-Arizona, told reporters after a meeting Tuesday at the State Department, "the president does have that authority, so I respect that."

Two former senior FBI agents who worked in counterintelligence, meanwhile, had different takes.

A former senior FBI official who asked not to be identified by name told NBC News he feared the Trump administration may seek to replace Comey with someone who will close the Russia probe.

But Jeffrey Harp, a former senior agent who retired in 2015, said, "Nothing will change."

"The FBI is not political," Harp said. "It would be politically suicidal to try to quash this investigation. They cannot do that — they never would be able to do that."

Comey had been scheduled to testify Thursday before a Senate Intelligence Committee hearing on worldwide threats. It wasn't immediately clear whether he would keep that engagement.

Sen. Bob Corker, R-Tennessee, released the following statement on Comey's firing:

“While the case for removal of Federal Bureau of Investigation Director James Comey laid out by Deputy Attorney General Rod J. Rosenstein was thorough, his removal at this particular time will raise questions,” said Corker. “It is essential that ongoing investigations are fulsome and free of political interference until their completion, and it is imperative that President Trump nominate a well-respected and qualified individual to lead the bureau at this critical time.”

Stay with for updates to this story.