Insurgencies led by religious extremists in Iraq and Syria are the most serious danger Britain faces today, David Cameron has warned.
The Prime Minister insisted the prospect of battle-hardened jihadists returning to the UK was a "real threat to our country".
But he denied that the Government was restoring diplomatic links with neighbouring Iran in a bid to win Tehran's help to quell the spread of Islamic State of Iraq and the Levant (Isis) militants.
Speaking at a joint press conference with Chinese premier Li Keqiang, Mr Cameron said: "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.
"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.
"We will do absolutely everything we can to keep our people safe. 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."
The comments came after Foreign Secretary William Hague said the "circumstances are right" to reopen the embassy in Tehran, which shut after being ransacked by a mob protesting against sanctions in 2011.
"There has never been any doubt in my mind that we should have an embassy in Tehran if the circumstances allowed," Mr Hague told MPs.
"Iran is an important country in a volatile region, and maintaining embassies around the world, even under difficult conditions, is a central pillar of the UK's global diplomatic approach."
He stressed there were "a range of practical issues" that had to be resolved before the base could start to operate again.
"Inevitably, the initial embassy presence will only able to offer a limited range of services at first. For the time being, Iranians will still need to apply in Abu Dhabi or Istanbul for visas for travel to the UK," he added.
A senior envoy was appointed as Britain's non-resident charge d'affaires last year, as relations improved after perceived moderate Hassan Rouhani was elected president. There has also been substantial progress reducing tensions over Iran's nuclear ambitions.
The move comes as the insurgency by the Islamic State of Iraq and the Levant (Isis) rages on, with more evidence emerging of brutal executions. Experts suggest Iran could play a vital role in helping to shore up the government in Baghdad.
But Mr Cameron rejected the idea that the diplomatic rapprochement was connected to the crisis.
"Britain believes in and I believe in step by step building our relationship with Iran because we need to have proper dialogue with that country.
"We are having dialogue over the nuclear weapons issue and I think we should be having dialogue with it on issues of regional security," the premier said.
"Obviously our relationship was at a low point after the appalling things that happened with respect to our embassy, but it is right step by step with a clear eye with a hard head, to rebuild that relationship.
"Now we would be doing that anyway irrespective of what is happening in Iraq, but I think what is happening in Iraq is certainly not a reason for not taking that step."
President Barack Obama announced last night that about 275 military personnel could deploy to provide support and security for the US embassy and its staff in Baghdad. The Iraqi government has asked America to carry out air strikes against the insurgents.
Secretary of state John Kerry has indicated that the administration is "open to discussions" with Iran if it can help end the violence and restore confidence in the Iraqi government, and he would not rule out military co-operation. Diplomats have already had initial contacts on the issue during nuclear talks in Austria.
On military co-operation, Mr Kerry said: "At this moment, I think we need to go step by step and see what, in fact, might be a reality.
"But I would not rule out anything that would be constructive in providing real stability, a respect for the constitution, a respect for the election process and a respect for the ability of the Iraqi people to form a government that represents all the interests of Iraq.
"We are open to any constructive process here that would minimise the violence."
Labour leader Ed Miliband welcomed the decision to reopen the embassy in Iran.
In a speech to Labour Friends of Israel, Mr Miliband said: "While it is absolutely right to remain deeply sceptical about the nature of the regime, we support the Government's decision today to reopen the embassy as a means of engagement."
The Labour leader added: " Iraq is today facing fundamental threats to its integrity, security and stability. Isis is a violent and brutal military group posing a threat to the entire region, as we have seen in a horrifying way in the last few days.
"Their advances in Iraq and their growing base in northern Syria should be seen by all as extremely grave developments.
"As (shadow foreign secretary) Douglas Alexander said yesterday, the priority now must be to promote the political integrity of Iraq, to help the Iraqi government through support and advice and do everything we can to provide humanitarian assistance.
"Nobody should be in any doubt about the seriousness of the situation and the priority it demands from the world."