United States troops cleared rubble and debris from a military base housing American soldiers in western Iraq on Monday, days after it was struck by a barrage of Iranian ballistic missiles in a major escalation between the two longtime foes.

The Iranian attack was in retaliation for the US drone strike near Baghdad airport that killed a top Iranian commander, General Qassem Soleimani, prompting angry calls to avenge his slaying.

Nearly eight hours before Iran's January 8 missile attack on US forces at bases in Iraq, American and Iraqi soldiers at Ain al-Assad airbase scrambled to move personnel and weaponry to fortified bunkers, according to two Iraqi officers stationed at the base.

By midnight, not a single fighter jet or helicopter remained out in the open, said one of the sources, an intelligence officer. Another Iraqi intelligence source said US troops even seemed to know the timing of the attack, saying they seemed "totally aware" the base would be attacked "after midnight", Reuters News Agency reported.

When the missiles finally landed at about 1:30am (22:30 GMT, January 7), they struck "empty bunkers that had been evacuated hours before", the intelligence source said. No one was injured or killed.

Such accounts add to the evidence the Iranian attack was among the worst kept secrets in modern warfare - but the reasons why remain mysterious after days of conflicting statements from officials in Iran, Iraq, and the United States.

More:

An Associated Press news agency crew touring the Ain al-Assad base Monday saw large craters in the ground and damaged military trailers, as well as forklifts, lifting rubble and loading it onto trucks from a large area the size of a football stadium.

The airbase in Iraq's western Anbar province is a sprawling complex about 180km (110 miles) west of Baghdad shared with the Iraqi military and housing about 1,500 members of the US military and the US-led coalition fighting the ISIL (ISIS) armed group.

The attack was Iran's most direct assault on the US since the 1979 seizure of the US Embassy in Tehran.

"There were more than 10 large missiles fired and the impact hit several areas along the airfield," said Colonel Myles Caggins, a spokesman for the US-led coalition fighting ISIL in Iraq and Syria.

He added the explosions knocked over concrete barriers and destroyed facilities that house dozens of soldiers.

Myles said soldiers received notification the missiles were on their way thanks to "early warning systems", and the troops were moved out of harm's way.

'Be aware'

An adviser to Iraq Prime Minister Adel Abdul Mahdi told Reuters that Iran did not directly notify Iraq until shortly before the missile attack - but said Iran passed warnings through other countries.

The adviser said both Iraq and the US were warned of the impending attack by one Arab country and one European country, declining the name them.

And who warned those countries?

"Iran, obviously," the adviser said. "Iran was keen that both the Americans and Iraqis be aware of the strikes before they occurred."

The Ain al-Assad airbase was first used by American forces after the 2003 US-led invasion that toppled dictator Saddam Hussein, and later saw American troops stationed there amid the fight against ISIL.

"I'd received information it was going to be a missile attack, and it was going to be Ain al-Assad," said Lieutenant-Colonel Antionette Chase of the US Army. "We were very well-prepared … Ten days prior, we had drilled for a similar attack."

Still, coalition troops said the missile barrage did not strike them as a display of restraint from Iran. As one US Air Force officer put it: "If you fire missiles at an airbase where people are maintaining aircraft 24/7, you're probably going to kill people."