The Washington Post reported that US officials said they knew by Tuesday afternoon that Iran intended to attack American targets in Iraq, although it was unclear which ones.
An early warning came from intelligence sources as well as communications from Iraq that conveyed Iran's intentions to launch the strike, the paper said.
David Martin, Pentagon correspondent for the BBC's US partner CBS, said a defence official told him the US was warned of the attack "multiple hours" before, giving plenty of time for troops to take shelter in bunkers.
The source said this warning came from a combination of satellites and signals and communications intercepts - the same systems that watch for North Korean tests.
But Mr Martin said he had not found anybody, including one very senior officer, who knew anything about a heads-up from the Iraqi prime minister. This official did not agree with speculation that Iran was aiming to miss.
"Our movements saved American lives," the official told him.
BBC defence correspondent Jonathan Marcus said: "Whether this was by design, or just due to shortcomings with the manufacture and accuracy of their missiles, as yet remains unclear. However, launching long range missiles against US bases is a risky way of making a point."
He added: "Looking at the initial civilian satellite pictures of the impacts of the Iranian missiles at Al Asad air base, they appear to have destroyed several structures, so the lack of casualties could be as much by luck rather than design."