Mr Trump said it was "a shame what happened"
US President Donald Trump has criticised FBI leaders while claiming to be "more loyal than anyone could be" to law enforcement.
He was referring to leaked documents which suggest a bias against him among some in the top ranks of the FBI.
Leaked text messages claimed top officials did not want him to become president.
It has emerged they called him a "loathsome human" and an "idiot".
Mr Trump said it was "a shame what happened" with the FBI as he travelled to the agency's headquarters to give an address.
Mr Trump called the agency's handling of the Hillary Clinton e-mail investigation "really disgraceful".
"We're going to rebuild the FBI," he said.
The leaked documents showed that top agents, one of whom was on the investigation into Mrs Clinton's e-mail use, believed that a Trump presidency would be a bad result.
As Mr Trump addressed the graduates of the FBI National Academy programme, he pledged his unwavering support.
He said: "Anti-police sentiment is wrong and it's dangerous. Anyone who kills a police officer should get the death penalty."
During his campaign he pledged to sign an executive order demanding capital punishment for those who kill police officers, but he has not yet done so.
He claimed to be "more loyal than anyone could be" to police.
In his speech, the president promoted his tough-on-crime policies, and celebrated his decision to make it easier for local police forces to purchase surplus military equipment.
He also spoke about Michael Flynn, a former national security adviser sacked after admitting he lied to the FBI about conversations with Moscow's special adviser.
He said: "When you look at what's gone on with the FBI and the Justice Department, people are very very angry."
He left the door open to the possibility of a presidential pardon for Flynn, but the White House said there was no plan to pardon him.
The president has always denied there was any collusion with Russia during his campaign for the White House.