Iran's foreign minister said on Thursday that Tehran had no intention of leaving Iraq and criticised "arrogant" Saudi Arabia for accusing it of stoking sectarian violence.
"We will leave Iraq whenever Iraq asks us to. And we will help Iraq to confront terrorism, as long as Iraq wants us to," Mohammad Javad Zarif said at a press conference in Stockholm during a European tour to attract investors.
On Sunday, Saudi Arabia accused Iran of sowing "sedition and division" in Iraq and sending in Shiite militias, and urged Tehran to "stop intervening" in the affairs of its neighbours.
But Zarif, whose Shiite-dominated country is an arch rival of Saudi Arabia, bristled at the remarks by the Sunni-led kingdom's Foreign Minister Adel al-Jubeir.
"It's an absurd statement, it's an arrogant statement. Nobody should arrogate themselves to talk on behalf of other countries," he said in English.
Tehran and Riyadh, a traditional ally of Washington, are at odds over a raft of regional issues, notably the conflicts in Syria and Yemen in which they support opposing sides.
Iran has advisors on the ground in Iraq and also in Syria to help the military in both countries battle armed groups fighting the national governments.
Saudi Arabia is also taking part in a US-led coalition targeting the Islamic State group in Syria and Iraq.
Without naming names, Zarif warned countries which consider groups such as IS and the Al-Qaeda linked Al-Nusra Front as "leverages that can be used for political gains".
"That's the worst miscalculation anybody has made in our region," he said.
"I believe the sooner Saudi Arabia comes to understand that ISIS is first and foremost a threat against them, then, anybody else, the sooner we are able to confront this total menace for all of us, not only in the region but in the world," Zarif added, using another acronym for the Islamic State group.