Comey was fired while on FBI business in Los Angeles. He learned of the firing from a news broadcast on television, and initially thought it was a prank. He is the second FBI Director to ever be dismissed by the President (the first being Bill Clinton’s dismissal of William Sessions).
Trump originally did so at the recommendation of his then-Attorney General Jeff Sessions. Sessions based his reasoning on a report by then-Deputy Attorney General Rod Rosenstein, who had criticized Comey’s handling of the investigation into Hillary Clinton’s email server. Despite the criticism, he never recommended dismissal.
The next day, White Press Secretary Sarah Huckabee Sanders revealed that Trump had considered firing Comey for some time. The day after that, Trump negated all of his own administration’s position, saying that he intended to fire Comey all along, and it was entirely his decision:
Lester Holt: “Monday, you met with Deputy Attorney General Rod Rosenstein. Did you ask for a recommendation?”
Trump: “What I did was, I was going to fire. My decision.”
Holt: “You’d made the decision before they came into the room?”
Trump: “I was going to fire Comey. There’s no time to do it.”
Holt: “In your letter, you said, ‘I accept their recommendation.’ ”
Trump: “Oh, I was going to fire, regardless of recommendation. He made a recommendation, he’s highly respected — very good guy, very smart guy. And the Democrats like him, Republicans like him. He made a recommendation, but regardless of recommendation, I was going to fire Comey.”
The day after the firing, he told two Russian officials in the Oval Office that firing Comey would ease pressure from the FBI investigation into Russian election interference. He later admitted to Lester Holt in an interview that he made the decision to fire Comey because of this investigation.
The Hill – Comey learned he was fired from TV, thought it was prank: reports
CBS News – Trump’s Clinton tweets cut against Comey firing explanation
The Washington Post – All of the White House’s conflicting explanations for Comey’s firing: A timeline
Wikipedia – William S. Sessions