The anger behind Donald Trump's firing of FBI Director James Comey on Tuesday had been building for months, but a turning point came when Comey refused to preview for top Trump aides his planned testimony to a Senate panel, White House officials said.

Trump, Attorney General Jeff Sessions and deputy Attorney General Rod Rosenstein had wanted a heads-up from Comey about what he would say at a May 3 hearing about his handling of an investigation into former Democratic presidential candidate Hillary Clinton's use of a private email server.

When Comey refused, Trump and his aides considered that an act of insubordination and it was one of the catalysts to Trump’s decision this week to fire the FBI director, the officials said.

"It gave the impression that he was no longer capable of carrying out his duties," one official said. Previews of congressional testimony to superiors are generally considered courteous.

Comey, who testified for four hours before the Senate Judiciary Committee, said it made him feel "mildly nauseous" that his decision to make public his reopening of a probe into Clinton's handling of classified information might have affected the outcome of the Nov. 8 presidential election. But he said he had no regrets and would make the same decision again.

Trump's sudden firing of Comey shocked Washington and plunged Trump deeper into a controversy over his campaign's alleged ties with Russia that has dogged the early days of his presidency.