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 program are successful.

The statement came as a top negotiator said Iran was hoping to start drafting a nuclear agreement with world powers Wednesday but accepts tough negotiations lie ahead on a raft of issues.

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.”

Nahavandian added that he was opposed to external intervention against Islamic militants from the Islamic State in Iraq and the Levant (ISIL) who have made sweeping gains in northern Iraq in recent days amid reports of the summary execution of hundreds of US-trained Iraqi soldiers.

“The management of the situation has to be given to the people and the government of Iraq. The Iraqi people and government have enough resources and commitment to defend itself,” he said.

“The outside world should just respond to what the government of Iraq wants (and) should not intervene in the management of the situation.”

He reiterated a previous Iranian commitment to respond to any request for help from the Iraqi government “to take care of the internal issue” and criticized US inaction.

“With regards to the United States, we have not seen any serious action from them against this wave of terrorism inside Iraq.”

Earlier in the day, negotiator Abbas Araqchi said Iran still hoped its differences with the six powers can be settled by a July 20 target date for a comprehensive deal, but that it “won’t be a catastrophe” if the negotiations have to be extended for another six months.

The main sticking points are the timetable for a full lifting of crippling US and EU sanctions, and the scale to which Iran would be allowed to continue uranium enrichment, he told Iran’s official IRNA news agency.

“We hope to start work on Wednesday on drafting the text of a final agreement, not the big issues but the general framework and the introduction,” Araqchi said.

“There is a still a long way to go before we reach an agreement acceptable to all sides.”

Iran and the six powers — Britain, China, France, Russia and the United States, plus Germany — opened a new round of talks in Vienna on Monday in the search for a deal by the July 20 deadline set by an interim agreement.

“We hope to reach an agreement between now and July 20,” Araqchi said.

“But if we don’t, it won’t be a catastrophe,” he added, referring to a clause in the interim agreement struck in November that allows for the talks to be extended.

Uranium enrichment is the sensitive process at the center of Western concerns about Iran’s nuclear ambitions.

It can produce both fuel for nuclear power stations and, in highly extended form, the core of an atomic bomb.