Image caption The UK has condemned Hamas after rockets were launched at targets in southern Israel

David Cameron has told Israeli PM Benjamin Netanyahu that Hamas "bears the principal responsibility" for the violence in southern Israel and Gaza.

But the UK prime minister urged both sides to avoid a spiral of violence in the region.

Eighteen Palestinians have been killed in the violence, while three Israelis died in cross-border missile fire.

The UK is advising against all but essential travel to within 25 miles (40km) of the Israel-Gaza border.

Israel killed Hamas' military chief in Gaza on Wednesday.

A Downing Street spokesman said: "The prime minister said that he was extremely concerned by the dangerous situation and deeply sorry for the loss of civilian life on both sides.

"He said the rocket attacks from Gaza into southern Israel by Hamas and other armed groups were completely unacceptable and that the increasing frequency of rocket attacks in recent days was the immediate cause of the situation.

"The prime minister said that the priority must be to de-escalate the crisis.

"He called on Mr Netanyahu to do all he could to avoid civilian casualties and emphasised that both sides needed to avoid a spiral of violence that would be in no one's interest, particularly at a time of instability in the region."

Mr Cameron hopes to speak to Egyptian President Mohammed Mursi about the crisis on Friday.

Media playback is unsupported on your device Media caption William Hague: "We call on all those involved to avoid any action which risks civilian casualties"

The Foreign Office has updated its travel advice to Israel and the Occupied Palestinian Territories.

It now states: "We now advise against all but essential travel to areas within 40km of Israel's border with Gaza; we continue to advise against all travel to Gaza (including the waters off Gaza) and to the Sheba'a Farms and Ghajjar along the border with Lebanon."

Earlier, UK Foreign Secretary William Hague said: "I utterly condemn rocket attacks from Gaza into southern Israel by Hamas and other armed groups."

But he also said Israel should do its "utmost to reduce tension".

Rocket attacks from Gaza create "an intolerable situation for Israeli civilians in southern Israel, who have the right to live without fear of attack" and "also risk worsening the plight of Palestinian civilians in Gaza, which is already precarious", he said.

The prime minister said that he was extremely concerned by the dangerous situation and deeply sorry for the loss of civilian life on both sides Downing Street spokesman

"Hamas and other armed groups in Gaza should cease attacks against Israel immediately. I call on those in the region with influence over Hamas to use that influence to bring about an end to the attacks.

"These events underline once again the fragility of the situation and the urgent need for progress toward a two state solution which allows Israelis and Palestinians to live alongside each other in peace and security.

"Britain will do all it can to support such progress and an urgent resumptions of negotiations."

At a news conference at the Foreign Office, Mr Hague conceded that the UK and other EU nations "don't have any direct control" over the situation but said he would be attempting to get his message across "very clearly" in meetings with Israel's and Egypt's foreign ministers.

Shadow foreign secretary Douglas Alexander called for "an immediate end to the violence to avoid a spiral downwards to even greater suffering".

He added: "Escalating tension serves no one's interest. Citizens in both Israel and Gaza deserve to live in peace and security.

"The recent rocket attacks into southern Israel that have led to this latest response deserve our categorical condemnation but Israel must at all times act in accordance with international law.

Media playback is unsupported on your device Media caption Tony Blair said it was urgent and essential to de-escalate the violence

"This latest escalation of violence only emphasises why it is vital that negotiations to achieve a political solution to the Israeli-Palestinian conflict must resume with urgency."

Former Prime Minister Tony Blair, who represents the UN, US, EU and Russia in the Middle East, told the BBC: "We are doing all we can to de-escalate the situation.

"We have got to stop the rocket attacks coming out of Gaza which means the Israeli retaliation ceases then put the situation back on a more stable footing. But if the violence continues then Israel will retaliate and this escalation could get a lot worse.

"It's essential we do it now or it will have an impact right across the region."