Iraq's prime minister's office said Wednesday it had received "an official verbal message" from Iran informing it that a missile attack on US forces stationed on Iraqi soil was imminent.

Iran launched 22 missiles at Iraqi bases housing US and other coalition troops early Wednesday in response to the killing of senior Revolution Guards commander Qasem Soleimani in a US drone strike in Baghdad last week.

In its first statement hours later, premier Adel Abdel Mahdi's office said it had been warned.

"We received an official verbal message from the Islamic Republic of Iran that the Iranian response to the assassination of Qasem Soleimani had begun or would begin shortly, and that the strike would be limited to where the US military was located in Iraq without specifying the locations," it said.

The prime minister's office said it was simultaneously contacted by the US, as the missiles slammed into the Ain al-Asad base in western Iraq and Harir further north.

The office of Iraqi prime minister Adel Abdel Mahdi says it was warned by Tehran of its imminent missile strikes on bases housing US troops without the specific locations
The office of Iraqi prime minister Adel Abdel Mahdi says it was warned by Tehran of its imminent missile strikes on bases housing US troops without the specific locations AFP / AHMAD AL-RUBAYE

"We immediately warned Iraqi military commanders to take the necessary precautions," it said, adding that no Iraqi forces had been hurt in the attack.

"Iraq rejects any violation of its sovereignty and attacks on its territory," the premier's office added, without specifically condemning the missile strikes.

It said Abdel Mahdi was in talks with domestic and foreign partners to prevent an "open war."

Secretary of State Mike Pompeo earlier said he had spoken to Masrour Barzani, the prime minister of the autonomous Kurdish region in northern Iraq.

But it remained unclear if there was any contact between Pompeo or any other top US official and Abdel Mahdi.