Media playback is unsupported on your device Media caption Trump speaks at FBI Academy graduation

US President Donald Trump has said he supports the FBI "100%", less than an hour after criticising the agency.

During a speech at the FBI National Academy's graduation in Virginia, Mr Trump heaped praise on the agency, saying it was full of "great people".

His visit comes only days after he described the agency as "in tatters" and "the worst in history".

Before travelling to the FBI campus on Friday, Mr Trump said people were "very angry" with the agency's actions.

"The president of the United States has your back 100%," he said later at the graduation ceremony in Quantico, Virginia.

"By the way, you are great people," he added. "I'd say like 90% are great, right? The other 10%, that's not working out so well."

Earlier this month, Mr Trump lambasted the agency and its former director, James Comey, whom he fired in May.

Skip Twitter post by @realDonaldTrump After years of Comey, with the phony and dishonest Clinton investigation (and more), running the FBI, its reputation is in Tatters - worst in History! But fear not, we will bring it back to greatness. — Donald J. Trump (@realDonaldTrump) December 3, 2017 Report

On his way to Quantico on Friday morning, Mr Trump struck a different tone, telling reporters that "its a shame what's happened with the FBI".

He appeared to refer to recent reports that two FBI agents had privately exchanged text messages during the 2016 election, which included disparaging remarks about then-candidate Mr Trump.

Republicans have claimed that the text exchange proves an anti-Trump bias in the special investigation being led by former FBI director Robert Mueller, who is examining possible campaign collusion with Russia and meddling in the US election process. Mr Trump denies that his team colluded with Russia to get him elected.

The two agents also reportedly insulted Democrats Bernie Sanders and Hillary Clinton, as well as other prominent political figures, according to the contents of the text messages released to US Congress and obtained by US media.

FBI regulations state that agents are permitted to express opinions "as an individual privately and publicly on political subjects and candidates".

"Immediately upon learning of the allegations, the special counsel's office removed [FBI agent] Peter Strzok from the investigation," said a spokesman for Mr Mueller earlier this month, referring to one of the agents in question.

Deputy Attorney General Rod Rosenstein defended the integrity of the Mueller investigation at a congressional hearing on Wednesday, saying: "We recognise we have employees with political opinions but it's our job to make sure those views... are not in any way a factor in how they conduct themselves in office."

In his remarks, Mr Trump also called for the death penalty for anyone who murders a police officer, and for Congress to reform the immigration process, which he blamed for recent attacks in New York City.

"With me as your president, America's police will have a true friend and loyal champion in the White House - more loyal than anyone else can be," he vowed.

He also said immigrants who enter the US through visa lotteries are "the worst of the worst".