US President Donald Trump has said he "did a great service" in firing former FBI director James Comey, following a report by the US Justice Department's inspector general on the agency's handling of an investigation into presidential candidate Hillary Clinton's use of a private email server in 2016.

Inspector General Michael Horowitz concluded in a long-awaited, 500-page report that Mr Comey made a "serious error of judgment" in announcing he was reopening the email server probe just before the 2016 US presidential election.

But he also found that Mr Comey did not exhibit political bias or try to influence the election, nor did Mr Horowitz contest the decision not to charge Mrs Clinton with a crime.

While the report was embarrassing for the FBI, it appeared to lack the kind of bombshell revelation that would significantly boost an effort by Mr Trump and his allies to paint the FBI as corrupt and discredit the Russia investigation.

"The IG Report is a total disaster for Comey, his minions and sadly, the FBI," Mr Trump said in a post on Twitter. 

Both sides of the partisan divide found something to trumpet in the report.

Democrats said it confirmed political bias did not influence the Clinton investigation, while Republicans seized on a newly disclosed text by an FBI agent in mid-2016 expressing his apparent intention to "stop" the Trump campaign.

Mr Comey defended his actions in an opinion piece published in the New York Times after the report was released.

"In 2016, my team faced an extraordinary situation something I thought of as a 500-year flood offering no good choices and presenting some of the hardest decisions I ever had to make," Mr Comey wrote.

A long-serving law enforcement official, Mr Comey became a controversial figure during the 2016 presidential election, drawing accusations from both Republicans and Democrats that his handling of the probe into Mrs Clinton's emails influenced the campaign.