Quantico, Va. — Taking aim at the credibility of the FBI, President Donald Trump unleashed a blistering attack on the bureau’s leadership even as he praised state and local police officers as a bulwark against rising violence and crime.

Trump denounced the bureau for its handling of the Hillary Clinton email investigation, calling it “really disgraceful” and continuing his practice of questioning his country’s intelligence and law enforcement institutions like no president before.

“It’s a shame what’s happened with the FBI,” the president said. “We’re going to rebuild the FBI, it’ll be bigger and better than ever, but it is very sad when you look at those documents, and how they’ve done that is really, really disgraceful and you have a lot of very angry people that are seeing it.”

The president’s broadside appeared to originate in anger over revelations that senior FBI officials exchanged anti-Trump and pro-Hillary Clinton text messages while working on last year’s Clinton probe and during special counsel Robert Mueller investigation into whether Trump associates colluded with Russian officials in the 2016 election.

In a head-spinning sequence, Trump laced into the bureau as he was set to depart for its training academy in Virginia, where he lavished praise on graduates of a weeks-long FBI National Academy program for law enforcement leaders from around the country.

He praised the graduates, who were trained on FBI standards, touting their accomplishments and pledging his unwavering support. Trump told law enforcement leaders he is “more loyal than anyone else could be” to police.

“Anti-police sentiment is wrong and it’s dangerous,” he added. “Anyone who kills a police officer should get the death penalty.”

Trump depicted a nation besieged by violence, using dark rhetoric that was a stark departure from the language of his predecessors. He evoked this week’s attempted terror attack in New York when he called for stricter immigration policies. He also delivered a stern warning to members of the international gang MS-13 that his administration will root them out and arrest them.

Trump celebrated his decision to make it easier for local police forces to purchase surplus military equipment, and questioned rising violence in Chicago.

“What the hell is going on in Chicago? What the hell is happening there?” asked Trump returning to a favorite campaign target.

The law enforcement crowd often chuckled and applauded its approval. Trump has often appeared at ease in front of police groups and loves to suggest that they supported him in last year’s campaign.

Violent crime has increased nationally the last two years but has dropped precipitously over the last quarter century. Gun violence in Chicago has dropped in 2017 from 2016 and of Dec. 10 there had been 620 homicides compared to 730 at the same time last year.

Hours before Trump’s speech, White House Deputy press secretary Hogan Gidley told Fox News Channel that edits to former FBI Director James Comey’s statement on Clinton’s private email server and anti-Trump texts from a top agent are “deeply troubling.”

“There is extreme bias against this president with high-up members of the team there at the FBI who were investigating Hillary Clinton at the time,” Gidley charged, as Mueller pushes on with a probe of possible Trump campaign ties to Russia. Gidley says Trump maintains confidence in the FBI’s rank-and-file.

Edits to the Comey draft appeared to soften the gravity of the bureau’s finding in its 2016 investigation of Hillary Clinton’s use of a private email server while secretary of state.

“It is very sad when you look at those documents, how they’ve done that is really, really disgraceful, and you have a lot of really angry people who are seeing it,” Trump said of the document.

Gidley said the disclosure of politically charged text messages sent by one of the agents on the Clinton case, Peter Strzok, were “eye-opening.” Strzok, who was in the room as Clinton was interviewed, was later assigned to special counsel Robert Mueller’s team to investigate potential coordination between Russia and the Trump campaign. He was re-assigned after the messages were uncovered this summer.

With the attack, the White House joined a growing movement among the conservative media and some Republicans to question the integrity of Mueller’s investigation.

About 200 leaders in law enforcement from around the country attended the weeks-long FBI National Academy program at Quantico aimed at raising law enforcement standards and cooperation. Coursework included intelligence theory, terrorism and terrorist mindsets, law, behavioral science, law enforcement communication, and forensic science.