Leaders of the US intelligence community told a Senate committee on Tuesday the nuclear threat from North Korea remained and Iran was not taking steps towards making a nuclear bomb, drawing conclusions that contrasted starkly with Trump's assessments of those countries.
"The Intelligence people seem to be extremely passive and naive when it comes to the dangers of Iran. They are wrong!" Trump said in a Twitter post.
The Republican president cited Iranian rocket launches and said that Tehran was "coming very close to the edge".
"Perhaps Intelligence should go back to school!" he said.
Trump last year pulled out of an international nuclear deal with Iran put in place under his Democratic predecessor Barack Obama, saying Tehran was "not living up to the spirit" of the agreement, and re-imposed sanctions.
Under the 2015 deal, Iran and world powers lifted international sanctions on Tehran. In return, Iran agreed to restrictions on its nuclear activities, increasing the time it would need to produce an atom bomb if it chose to do so.
The US intelligence officials told the Senate Intelligence Committee Iran was not developing nuclear weapons in violation of the agreement, even though Tehran has threatened to reverse some commitments after Trump pulled out of the deal.
Their assessments also broke with other assertions by Trump, including on the threat posed by Russia to US elections, the threat that the Islamic State of Iraq and the Levant (ISIL, also known as ISIS) armed group poses in Syria and North Korea's commitment to denuclearisation.
Trump has clashed with leaders of the US intelligence community even before he took office, most strikingly in casting doubt on their finding that Russia interfered in the 2016 US election with a campaign of hacking and propaganda to help him win the presidency.
Former CIA Director John Brennan last year called Trump's performance at a joint news conference with Russian President Vladimir Putin "nothing short of treasonous" after Trump seemed to give credence to Putin's denial of Russia meddling in the 2016 election.
Trump then revoked Brennan's security clearance.
Brennan wrote on Twitter on Wednesday that Trump's refusal to accept the US intelligence community's assessments on Iran, North Korea, ISIL, Russia and other matters shows the extent of what he called the president's "intellectual bankruptcy".
Nine days before assuming the presidency, Trump accused the intelligence community of leaking false information, saying "that's something that Nazi Germany would have done".
Trump has invested heavily in improving relations with North Korea in hopes of getting the reclusive nation to abandon its nuclear ambitions.
He broke with decades of US policy when he agreed to meet with North Korean leader Kim Jong Un last June and has planned a second summit in February.
"North Korea relationship is best it has ever been with US. No testing, getting remains, hostages returned. Decent chance of Denuclearization," Trump said in a Twitter post, drawing a comparison to the "horrendous" relationship under Obama.
"Now a whole different story. I look forward to seeing Kim Jong Un shortly. Progress being made-big difference!"
Director of National Intelligence Dan Coats and CIA Director Gina Haspel told senators that North Korea viewed its nuclear programme as vital to its survival and was unlikely to give it up.
Trump also defended his decision to withdraw 2,000 US troops from Syria on grounds that ISIL no longer poses a threat, saying "we've beaten them".
"Caliphate will soon be destroyed, unthinkable two years ago," Trump said on Twitter.
The US spy chiefs said ISIL will continue to pursue attacks from Syria and Iraq against regional and Western adversaries, including the US.
Intelligence committee member Senator Angus King, an independent who caucuses with Democrats, told CNN, "It's still disturbing that the president doesn't seem to want to listen to the people whose job it is to give him this information."