President Donald Trump warned Iran on Wednesday of a "heavy price" if it or its allies in Iraq attack US troops stationed there.

"We don't want hostility, but if they are hostile to us, they're going to regret it like they've never regretted anything before," he said of Iran at a White House press briefing on the coronavirus pandemic.

"If this happens, Iran will pay a very heavy price, indeed!" Trump tweeted earlier in the day.

The US president also wrote: "Upon information and belief, Iran or its proxies are planning a sneak attack on US troops and/or assets in Iraq."

It was not clear whether Trump meant Washington actually has intelligence of such a plan.

Tensions between the arch-foes -- already high since Trump abandoned a landmark nuclear agreement in 2018 and reimposed sweeping sanctions -- have soared since the US killing of Tehran's foreign operations chief Major General Qasem Soleimani in a drone strike just outside Baghdad airport in January.

The US and Iran are locked in a tense battle for influence in Iraq, where Tehran has powerful allies, including among armed militias, and Washington has close ties to the government.

Some 7,500 foreign troops are in Iraq as part of the US-led coalition helping local troops fight jihadist groups, but those numbers are being significantly drawn down this month.

The alliance is temporarily bringing some trainers home as a precautionary measure against the coronavirus pandemic and is also leaving some Iraqi bases altogether.

Those bases and foreign embassies, particularly the American mission, have been targeted in more than two dozen rocket strikes since late October.

US President Donald Trump, pictured here at a press briefing, is warning Iran against attacks on US troops in Iraq
US President Donald Trump, pictured here at a press briefing, is warning Iran against attacks on US troops in Iraq AFP / MANDEL NGAN

The attacks, which the US has blamed on an Iran-backed armed group, have prompted fears of a proxy war on Iraqi soil.

Earlier on Wednesday Iran hit out at US sanctions, as its own virus death toll passed 3,000.

Tehran has repeatedly called on Washington to reverse its policy, which has been opposed by US allies, particularly since the COVID-19 pandemic hit.

President Hassan Rouhani accused Washington of missing a "historic opportunity" to lift sanctions.

"This was a humanitarian issue. No one would have blamed them for retreating," he said.

Medicines and medical equipment are technically exempt from the US sanctions but purchases are frequently blocked by the unwillingness of banks to process purchases for fear of incurring large penalties in the United States.