President Donald Trump criticized the assessments of the U.S. intelligence community on Wednesday after the heads of the CIA, the FBI and other intelligence agencies contradicted him on threats posed by Iran, North Korea and ISIS.

"The Intelligence people seem to be extremely passive and naive when it comes to the dangers of Iran. They are wrong! When I became President Iran was making trouble all over the Middle East, and beyond. Since ending the terrible Iran Nuclear Deal, they are MUCH different, but a source of potential danger and conflict," Trump said on Twitter.

"They are testing Rockets (last week) and more, and are coming very close to the edge. There [sic] economy is now crashing, which is the only thing holding them back. Be careful of Iran. Perhaps Intelligence should go back to school!"

The Intelligence people seem to be extremely passive and naive when it comes to the dangers of Iran. They are wrong! When I became President Iran was making trouble all over the Middle East, and beyond. Since ending the terrible Iran Nuclear Deal, they are MUCH different, but.... — Donald J. Trump (@realDonaldTrump) January 30, 2019

The heads of various branches of U.S. intelligence testified on Tuesday about the threats the country faces from foreign powers at the Senate Intelligence Committee's annual worldwide threats hearing. It featured public testimony from CIA director Gina Haspel, FBI director Christopher Wray and Dan Coats, the director of national intelligence.

Despite Trump's claim that Iran continues to work on building nuclear weapons, the intelligence chiefs said Tehran was complying with the 2015 agreement to curb its nuclear program in exchange for sanctions relief. The deal — officially called the JCPOA, or Joint Comprehensive Plan of Action — was struck under the Obama administration. Trump withdrew from the deal last May and re-imposed economic sanctions, but other countries party to the agreement, including France and Germany, pledged to continue working on a broader Iran nuclear deal.

"At the moment, technically they're in compliance, but we do see them debating amongst themselves as they fail to realize the economic benefits they hope for from the deal," Haspel told the committee on Tuesday.

Trump also blasted intelligence assessments of threats posed by ISIS and North Korea that ran counter to foreign policy and national security accomplishments he has touted.

"When I became President, ISIS was out of control in Syria & running rampant. Since then tremendous progress made, especially over last 5 weeks. Caliphate will soon be destroyed, unthinkable two years ago," Trump said in one tweet on Wednesday.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

He later added, "North Korea relationship is best it has ever been with U.S. No testing, getting remains, hostages returned. Decent chance of Denuclearization..."

In December, Trump declared victory over ISIS and announced that he was withdrawing American troops from Syria — a sudden policy shift that blindsided Congress, officials at the Pentagon and State Department and also prompted the resignation of then-Defense Secretary Jim Mattis.

On North Korea, Trump announced a denuclearization deal with Kim Jong Un last June at the conclusion of a high-profile summit in Singapore. The president has continued to boast on Twitter and in speeches that the authoritarian regime has dramatically reduced its nuclear testing and making progress toward complete denuclearization. In June, Trump tweeted that there was "no longer a nuclear threat" from North Korea.

However, U.S. officials previously told NBC News that Pyongyang has continued to develop ballistic missiles at undeclared sites and researchers have discovered as many as 20 undisclosed missile sites in the country.

During Tuesday's hearing, Coats contradicted the president when he noted that U.S. intelligence agencies believe North Korea is unlikely to completely give up its nuclear weapons because "its leaders ultimately view nuclear weapons as critical to regime survival."

"Our assessment is bolstered by our observations of some activity that is inconsistent with full denuclearization. While we assess that sanctions on exports have been effective and largely maintained, North Korea seeks to mitigate the effects of the U.S.-led pressure campaign through diplomatic engagement," he said.

Coats also refuted Trump's previous claim that ISIS is defeated in Syria. He testified that the group was "nearing" military defeat in Iraq, but has returned to its "guerrilla warfare roots while continuing to plot attacks."

"ISIS is intent on resurging and still commands thousands of fighters in Iraq and Syria," he said.

U.S. intelligence also concluded that countries such as Russia, China and Iran may also seek to influence American politics going forward after the efforts by Russia during the 2016 election.

Former CIA director John Brennan excoriated the president in a tweet on Wednesday for undermining the assessment of the U.S. intelligence community, calling the president a danger to national security.

"Your refusal to accept the unanimous assessment of U.S. Intelligence on Iran, No. Korea, ISIS, Russia, & so much more shows the extent of your intellectual bankruptcy. All Americans, especially members of Congress, need to understand the danger you pose to our national security," he said.

Your refusal to accept the unanimous assessment of U.S. Intelligence on Iran, No. Korea, ISIS, Russia, & so much more shows the extent of your intellectual bankruptcy. All Americans, especially members of Congress, need to understand the danger you pose to our national security. https://t.co/9iV3BTKiEv — John O. Brennan (@JohnBrennan) January 30, 2019

Rep. Adam Schiff, D-Calif., the chairman of the House Intelligence Committee, said it was "deeply dangerous that the White House isn't listening" to the consensus of the intelligence community.

"It is a credit to our intelligence agencies that they continue to provide rigorous and realistic analyses of the threats we face," he said on Twitter. "It's deeply dangerous that the White House isn't listening."

It is a credit to our intelligence agencies that they continue to provide rigorous and realistic analyses of the threats we face.



It’s deeply dangerous that the White House isn’t listening. https://t.co/rCKywL0ETK — Adam Schiff (@RepAdamSchiff) January 30, 2019

Sen. Bernie Sanders, I-Vt., also criticized Trump for not believing intelligence agencies.

"I think that a President of the United States might want to be listening to people who have made their entire lives the understanding of intelligence gathering and what's going on in the world," he said on Wednesday.

Sen. Cory Gardner, R-Colo., a member of the Senate Foreign Relations Committee, told Fox News on Wednesday that although Trump has made progress on the War on Terror, the intelligence community has been clear that ISIS has not been wiped out.

He added that the country cannot afford another "mission accomplished moment" regarding ISIS — referring to then-President George W. Bush's infamous May 2003 speech declaring that American operations had ended in Iraq and that the "United States and our allies have prevailed" when the war effort and resulting causalities would in fact escalate in the years to come.

"The bottom line is this isn't over. We haven't destroyed it. Our intel community is very clear, we have to keep the pressure, we have to keep the work, and we have to safeguard the American people from this ideology and these people that wish to do us great harm,” Gardner said.