President Trump’s dysfunctional leadership with the Department of Justice, FBI and other intelligence operations is harming the rule of law in the United States, former Defense Secretary Leon Panetta said Sunday.

Panetta said on “Fox News Sunday” Trump’s frequent criticisms of the FBI, DOJ officials, and the CIA is weakening the trust between the White House and the federal law enforcement community. The ex-CIA director said it creates a crisis.

“In order for our democracy to function, you have to have a relationship of trust between the president and those who are responsible for enforcing the law, the Justice Department and the FBI,” he said. “And if that trust breaks down, then I think it does undermine the rule of law in this country, and that, in effect, creates a crisis.”

Trump has been critical of the intelligence community for years, including during the 2016 campaign when he ripped the intelligence that led the United States into the war in Iraq in 2003. During the transition, he often criticized the intelligence community’s work investigating Russian meddling in the 2016 election because he felt he won the election on his own with no help from the Kremlin.

The intelligence community has determined the Russian government ran an influence campaign on the 2016 election to harm Hillary Clinton and eventually developed a preference for Trump.

“The president frankly needs to focus on the economy, on infrastructure, on improving the ability of all Americans in order to succeed in our country,” Panetta said. “That's what presidents need to focus on. And if he spends his time tweeting about the investigation or trying to tweet about undermining the FBI, very frankly he's going to hurt his presidency.”

Rumors are swirling that Trump is preparing to fire Deputy Attorney General Rod Rosenstein — who is the person with direct authority over special counsel Robert Mueller as he investigates Russian meddling in the election — and Panetta said that would be a huge blunder by Trump.

“It's a big mistake. These are people that he appointed for office. At least for my impression these are people who are credible in trying to do their job in a conscientious and dedicated way,” he said.

“I think if he tries to go after them and tries to somehow appear to be obstructing the process that's involved in this investigation, he's going to hurt himself, he's going to hurt the presidency, but more importantly, he's going to hurt the country.”