The cyber-attack disabled computer systems controlling rocket and missile launchers, the Washington Post said.
It was in retaliation for the shooting down of a US drone as well as attacks on oil tankers that the US has blamed Iran for, the New York Times said.
There is no independent confirmation of damage to Iranian systems.
The US has also imposed sanctions President Trump described as "major".
He said the sanctions were needed to prevent Iran from obtaining nuclear weapons and economic pressure would be maintained unless Tehran changed course.
Tensions between the US and Iran have risen since the US last year pulled out of a 2015 nuclear deal between Iran and world powers and reinstated sanctions, triggering economic meltdown in Iran.
Last week Iran said it would exceed internationally agreed limits on its nuclear programme.
Mr Trump has said he does not want war with Iran, but warned it it would face "obliteration" if conflict broke out.
The attack had been planned for several weeks, the sources told several US media outlets, and was suggested as a way of responding to the mine attacks on tankers in the Gulf of Oman.
It was aimed at weapons systems used by Iran's Islamic Revolutionary Guard Corps (IRGC), which shot down the US drone last Thursday and which the US says also attacked the tankers.
Both the Washington Post and AP news agency said the cyber-attack had disabled the systems. The New York Times said it was intended to take the systems offline for a period of time.
On Saturday the US Department for Homeland Security warned that Iran was stepping up its own cyber-attacks on the US.
Christopher Krebs, the director of the Cybersecurity and Infrastructure Security Agency, said "malicious cyberactivity" was being directed at US industries and government agencies by "Iranian regime actors and their proxies".
They were using "destructive 'wiper' attacks", he said, using tactics such as "spear phishing, password spraying and credential stuffing" in a bid to take control of entire networks.
Iran has also been trying to hack US naval ship systems, the Washington Post reported.