A top Iranian official said on Wednesday that Tehran could consider working with the United States over the crisis in Iraq if talks on its nuclear programme are successful.
Asked about possible cooperation in Iraq, President Hassan Rouhani's chief of staff Mohammad Nahavandian told reporters in Oslo that the nuclear talks were a "test for confidence building".
"If that comes to a final resolution, then there might be opportunities for other issues to be discussed."
The rise of the jihadist Islamic State in Iraq and the Levant (ISIL), which has made sweeping gains in northern Iraq in recent days, has raised speculation over cooperation between Washington and Tehran to help stop the insurgency.
And on Monday, US Deputy Secretary of State William Burns held a brief meeting with Iranian officials in Vienna on the sidelines of the nuclear talks.
Signup to our newsletter and follow us on Facebook and Twitter!
Nahavandian said he was opposed to any foreign intervention in Iraq unless it was requested by the government, but also criticised US inaction.
"The outside world should just respond to what the government of Iraq wants (and) should not intervene in the management of the situation.
"With regards to the United States, we have not seen any serious action from them against this wave of terrorism inside Iraq."
Rouhani said Wednesday that Iran would do whatever it takes to protect revered Shiite Muslim holy sites in Iraq against the Sunni ISIL militants.
Meanwhile, Nahavandian said he believed a July 20 deadline for Iran and world powers to reach a deal on Tehran's nuclear drive could be met.
"There are many people around the world who look optimistically to the ongoing negotiations and I am not an exception to that rule," he said.