Four people were killed when two Palestinians stormed a Jerusalem synagogue today, attacking worshippers praying inside with knives, axes and guns.

The attackers were then killed in a shoot-out with police.

The attack, the deadliest in Jerusalem in years, is bound to ratchet up fears of sustained violence in the city, already on edge amid soaring tensions over a contested holy site.

Prime Minister Benjamin Netanyahu vowed that Israel would "respond harshly" to the attack, describing it as a "cruel murder of Jews who came to pray and were killed by despicable murderers".

US Secretary of State John Kerry said he spoke to Mr Netanyahu after the attack and denounced it as an "act of pure terror and senseless brutality and violence".

Israeli police called it a terrorist attack and said the two Palestinian assailants were cousins from east Jerusalem. It was not immediately known if they were affiliated with any group. Hamas, the militant Palestinian group which runs the Gaza Strip, praised the attack but stopped short of claiming responsibility.

Police spokesman Micky Rosenfeld said six other people were injured in the attack, including two police officers. Four of those wounded were reported to be in a serious condition. He said police were searching the area for other suspects.

Associated Press footage from the scene showed the synagogue, in Jerusalem's ultra-Orthodox Har Nof neighbourhood, surrounded by police and rescue workers following the attack.

Wounded worshippers were being assisted by paramedics and a bloodied butcher's knife lay near the scene of the attack.

"I tried to escape. The man with the knife approached me. There was a chair and table between us ... my prayer shawl got caught. I left it there and escaped," Yossi, who was praying at the synagogue at the time of the attack, told Israeli Channel 2 TV. He declined to give his last name.

A photo in Israeli media from inside the synagogue showed what appeared to be a body on the floor draped in a prayer shawl, with blood spattered nearby.

Police spokeswoman Luba Samri said the attackers were Palestinians from east Jerusalem, which has been the scene of relentless clashes between Israeli police and Palestinian protesters in recent months.

Jerusalem itself has seen a spate of attacks by Palestinians against Israelis. At least six people have been killed in the city, the West Bank and Tel Aviv in recent weeks, prior to today's casualties.

Jerusalem residents have already been fearful of what appeared to be lone wolf attacks using cars or knives against pedestrians. But today's synagogue attack harks back to the gruesome attacks during the Palestinian uprising of the last decade.

Israel's police chief said today's attack was probably not organised by militant groups, similar to other recent incidents, making it more difficult for security forces to prevent the violence.

"These are individuals that decide to do horrible acts. It's very hard to know ahead of time about every such incident," Yohanan Danino told reporters at the scene.

Tensions appeared to have been somewhat defused last week following a meeting between Mr Netanyahu, Mr Kerry and Jordan's King Abdullah II in Amman. The meeting was an attempt to restore calm after months of violent confrontations surrounding a sacred shrine holy to both Jews and Muslims.

Israel and the Palestinians said then that they would take steps to reduce tensions which might lead to an escalation.

In his statement, Mr Netanyahu blamed the violence on incitement by both Hamas and Palestinian President Mahmoud Abbas and said the international community ignores the incitement.

Mr Kerry blamed the attack on Palestinian calls for "days of rage", and said Palestinian leaders must take serious steps to refrain from such incitement. He also urged Palestinian leaders to condemn the attack "in the most powerful terms".

Hamas's statement praised the synagogue attack, saying it was a "response to continued Israeli crimes, the killing, desecrating al-Aqsa (mosque)" - a reference to a recent incident at the holy site.

Much of the recent violence stems from tensions surrounding the Jerusalem holy site referred to by Jews as the Temple Mount because of the Jewish temples that stood there in biblical times. It is the most sacred place in Judaism; Muslims refer to it as the Noble Sanctuary, and it is their third holiest site, after Mecca and Medina in Saudi Arabia.

The site is so holy that Jews have traditionally refrained from going there, instead praying at the adjacent Western Wall. Israel's chief rabbis have urged people not to ascend to the area, but in recent years, a small but growing number of Jews, including ultranationalist politicians, have begun regularly visiting the site.

Palestinian President Abbas also condemned the attack and called for an end to Israeli "provocations".