After abruptly dismissing FBI Director James Comey on Tuesday, President Donald Trump took to Twitter to defend his decision.

@realDonaldTrump: Cryin' Chuck Schumer stated recently, "I do not have confidence in him (James Comey) any longer." Then acts so indignant. #draintheswamp

@realDonaldTrump: The Democrats have said some of the worst things about James Comey, including the fact that he should be fired, but now they play so sad!

@realDonaldTrump: James Comey will be replaced by someone who will do a far better job, bringing back the spirit and prestige of the FBI.

@realDonaldTrump: Comey lost the confidence of almost everyone in Washington, Republican and Democrat alike. When things calm down, they will be thanking me!

@realdDonaldTrump: Watching Senator Richard Blumenthal speak of Comey is a joke. "Richie" devised one of the greatest military frauds in U.S. history. For....

@realDonaldTrump: years, as a pol in Connecticut, Blumenthal would talk of his great bravery and conquests in Vietnam - except he was never there. When....

@realDonaldTrump: caught, he cried like a baby and begged for forgiveness...and now he is judge & jury. He should be the one who is investigated for his acts.

@realDonaldTrump: The Roger Stone report on @CNN is false - Fake News. Have not spoken to Roger in a long time - had nothing to do with my decision.

In Trump's letter to Comey, the president said, "It is essential that we find new leadership for the FBI that restores public trust and confidence in its vital law enforcement mission."

The White House said its search for Comey's successor begins immediately. Andrew McCabe, who has been the FBI's deputy director, is now acting director, a Justice Department official told NBC.

The president's firing of Comey now raises concerns it could create a sideshow that may delay the Trump agenda, analysts were saying Tuesday evening.

Stocks have traded around record levels since Trump won the election, but the market is no longer favoring equities that would show a clear benefit from Trump's policies on infrastructure spending or even tax reform.

—CNBC's Christine Wang and Patti Domm contributed to this report.