The UK has confirmed it wants to work closely with Iran to dismantle the Islamic State (Isis).

"The Iranian deal creates the possibility of an opening to a more constructive dialogue with Iran, which will be important in the context of what happens in Iraq," the UK's foreign secretary, Philip Hammond, told the Foreign Affairs Committee on 21 July.

Both the UN Security Council and the EU's foreign ministers endorsed a deal on 20 July that will lift economic sanctions on Iran. The agreement will see the sanctions lifted in exchange for limits on Iran's nuclear program.

Hammond quickly curbed enthusiasm about Iran's immediate role in fighting IS, however. "We can't bank on that yet," he said, noting that in the wake of the deal there "may be a spike in Iranian unhelpful activity in the region".

Ali Khamenei, supreme leader of Iran, took to Twitter over the weekend following his approval of the deal to condemn the US, and its ally the UK.

US Secretary of State John Kerry, who brokered the deal with Iran, called Khamenei's remarks "very disturbing".

"The one thing that we can say is that Iran shares our concern. To put it mildly – they see [IS] as a mortal enemy that needs to be eradicated," said Hammond.

During the negotiations for the deal with Iran, Sir Simon Gass, director general of the Foreign Office, said Iran's foreign minister Mohammad Javad Zarif told him the UK and Iran "don't have common interests, but common challenges".

With their control of Shia militias in Iraq, and a view to countering Saudi power in the Middle East, "we will always need to work carefully with Iran," said Gass. "I don't see us becoming great friends."

What Hammond hopes to see happen in the region — and in Syria specifically — is a political transition from the regime of President Bashar al-Assad "to a government that has legitimacy, that can then take the fight to IS".

"What we mustn't do in Syria is make the mistake of repeating Iraq," he said, "by dismantling the government institutions and leaving a power vacuum in its place".

Hammond added that the UK will continue to train and equip moderate opposition groups fighting Assad's forces. With their help and that of Iran, he hopes for eventual political legitimacy at the top of Syria that can be endorsed "by all the competing moderate groups".

To get there, he acknowledged, will "require some change in the way Iran engages with the international community".