Cameron committed to 'rebuilding' relations with Iran
David Cameron has said he is committed to "rebuilding" diplomatic relations with Iran but will proceed with a "clear eye and hard head".
The UK prime minister said the reopening of the British embassy in Tehran, announced on Tuesday, was an important step in that process.
He also warned the fallout from the conflicts in Syria and Iraq were the UK's most serious security threat.
Up to 400 UK nationals are believed to be fighting with Sunni militant groups.
Full diplomatic relations with Iran were suspended after attacks on the British embassy in Iran in 2011 but UK Foreign Secretary William Hague said the "circumstances were right" for the embassy to reopen following an improvement in bilateral relations in recent months.
The move comes as Iraqi forces are engaged in heavy clashes with Sunni Islamist militants across the country and amid reports that Iran is providing military assistance to its historic rival.'All-time low'
The election of a new Iranian president and a deal on Iran's nuclear programme has led to renewed contacts between the UK and Iran this year.
Speaking at a press conference in Downing Street after talks with Chinese premier Li Keqiang, Mr Cameron said the "appalling attack" in 2011 had brought UK-Iranian relations to an "all-time low".
But he said it was right that the two countries should engage in "greater dialogue" and seek to improve relations on a "step-by-step" basis.
The shared interest in confronting militants led by the Islamic State in Iraq and the Levant (ISIS) has accelerated contacts between the West and Iran.
Mr Cameron said he would have supported improved relations with Iran in any case but "what is happening in Iraq is not a reason for not taking that step".
The UK has ruled out any role in future military intervention in Iraq and Mr Cameron said it was incumbent on the Iraqi government to "pursue an inclusive process that can unite the country".
He also pledged to do everything he could to protect people from UK nationals fighting alongside Jihadi militants fighting in Iraq and Syria if they return to the UK.
"No-one should be in any doubt that what we see in Syria and now in Iraq in terms of Isis is the most serous threat to Britain's security that there is today," he said.
"The number of foreign fighters in that area, the number of foreign fighters including those from the UK who could try to return to the UK, this is a real threat to our country," he said.
"That means stopping people from going, it means arresting people who are involved in plots, it means focusing our security, our policing, our intelligence effort on to that area of the world, on to those people."
Earlier on Tuesday, Mr Hague said the UK embassy would re-open "as soon as practical arrangements are made" as a sign of "increasing confidence" in the state of relations between the two countries.
The foreign secretary said he had sought assurances that British diplomatic staff would be safe and would be able to carry out their work "without hindrance".
Speaking in Parliament, Mr Hague rejected suggestions that the move amounted to a "softening" of the UK's approach towards Iran and stressed the UK wanted to see a change in its foreign policy.
Tehran must "cease support for sectarian groups across the Middle East and reach a successful conclusion to nuclear negotiations", he told MPs.
Analysis by Kasra Naji, BBC Persian
Efforts to establish normal relations between UK and Iran were stepped up last year soon after the election of President Hassan Rouhani. He had promised to mend Iran's relations with the outside world.
Iran's relations with many countries had taken a turn for the worse during the previous eight years of disastrous foreign policy adventures under President Mahmoud Ahmadinejad.
It was on his watch that angry Islamic hard-line supporters of the government attacked and ransacked British embassy buildings in Tehran in November 2011. Now the two countries are trying to put all that behind them. Both countries need each other, and it seems the need for co-operation on stopping the advance of Isis in Iraq has given the efforts to improve relations a new impetus.
Britain needs Iran to help establish a broad-based government in Iraq. But there are still unresolved problems. Iran says it will not apologise for the attack that broke all diplomatic norms, although it says it is willing to discuss paying for the damages to the buildings.
The safety of Iranian staff working for the British embassy is another issue that needs firm guarantees from the Iranian side. But for ordinary people, the reopening of the embassies cannot come soon enough.
Tens of thousands of Iranians, many of them students, live in Britain. They and their families need visas and consulate services that they are not getting at the moment.
The storming of the British embassy in 2011, in retaliation for UK support for sanctions against Tehran, was one of series of incidents in the past decade that have ratcheted up tensions between the countries.
In 2007, 14 Royal Navy sailors were detained by the Iranian authorities after they were accused of violating Iranian territorial waters.
The appointment of a UK-based British charge d'affaires to Tehran last year was seen as a sign of a thaw in relations. However, the UK government still has concerns about Iran's role in Syria, where it is supporting the government of Bashar al-Assad in its fight against rebel groups and its backing for Hezbollah in Lebanon.
The US broke off diplomatic relations with Iran in 1980 after 52 of its embassy staff were held hostage in Tehran.