The gruesome slaying of five Israelis at a synagogue early Tuesday left many residents of this city fearing that the worst is still to come, as Jerusalem descends deeper into a cycle of terror attacks and violent protest over its religious sites.

Many Israelis were especially stunned by the sense of violation created by the attack, in which two Palestinians armed with cleavers and a gun stormed a synagogue in an Orthodox Jewish neighborhood of West Jerusalem and killed four rabbis: a Briton and three Americans, including a member of two of Orthodox Judaism’s most prominent families.

Late Tuesday, an Israeli police officer who rushed to the scene died of wounds suffered in the attack, and Israeli forces threatened to begin demolishing the family homes of Palestinians who have attacked Israelis. The Palestinian assailants, cousins from majority-Arab East Jerusalem, were killed at the scene by police.

Photographs of the attack’s aftermath, released by the Israeli government, showed prayer shawls, an open prayer book and the arm of one of the four rabbis, wrapped in scripture-laden tefillin, lying in pools of blood.

Israeli Prime Minister Benjamin Netanyahu on Tuesday night accused Palestinian leaders of inciting the violence and committing “blood libel” by suggesting that Jews were responsible for the death this week of a Palestinian bus driver who Israeli police say committed suicide by hanging.

Two Palestinian men allegedly killed four people with axes and knives inside a synagogue in Jerusalem early Tuesday, before police shot them dead. The attack happened in an ultra-Orthodox neighborhood of West Jerusalem. (Reuters)

Tuesday evening, Netanyahu ordered the destruction of the East Jerusalem homes of those linked to recent attacks. Seven Israelis have been killed in recent weeks as Palestinians rammed a car into passengers awaiting a Jerusalem Light Rail train and slashed people with knives at a bus stop in the West Bank and at a train station in Tel Aviv.

The home-razing tactic was common a decade ago, but Israel has rarely used it in recent years. Netanyahu said Tuesday the demolitions are an effective deterrent against further attacks.

“This is a battle over Jerusalem,’’ he said in a nationally televised address, insisting that Israelis would never give up their claims to the contested city. Palestinians want East Jerusalem, which is annexed and occupied by Israel, to be the capital of any future Palestinian state.

The Palestinian Authority’s president, Mahmoud Abbas, denounced Tuesday’s slayings and said such attacks “violate all religious principles and do not serve the common interest we are trying to promote – establishing a Palestinian state alongside the State of Israel.”

The Israeli newspaper Haaretz quoted Yoram Cohen, the chief of the Israeli domestic security agency Shin Bet, as saying Abbas has not been inciting terror attacks.

That could not be said of the Islamist Palestinian militant movement Hamas, based in the Gaza Strip. Its spokesman, Sami Abu Zahri, praised what he called “the Jerusalem operation” and called for a “continuation of the revenge operations.”

Hamas did not assert responsibility for Tuesday’s attack, but loudspeakers in Gaza praised the Palestinians who carried it out. Zahri said it was a response to the “execution” of the Palestinian bus driver, Yusuf Hasan al-Ramuni, who was found hanging in his bus Monday. An Israeli autopsy concluded that his death was a suicide.

The Popular Front for the Liberation of Palestine, another militant organization, asserted responsibility for the synagogue attack. But police said they were still investigating the claim, and relatives of the Palestinian assailants said the cousins were not members of any Palestinian faction.

The attack took place in the quiet West Jerusalem neighborhood of Har Nof, popular with Americans and others undertaking studies in Judaism. Among the dead was Mosheh Twersky, dean of an English-speaking religious school in Jerusalem and a member of one of the most respected families in Orthodox Jewish scholarship.

The State Department identified the other slain Americans as Aryeh Kupinsky and Cary William Levine (who was also known as Kalman Levine). Israeli authorities identified the British victim as Avraham Goldberg. All had dual Israeli citizenship.

Ya’akov Amos, who was inside the synagogue at the time of the attack, described the scene as one of carnage and shock.

“I was praying quietly when all of a sudden I heard gunshots from outside in the hallway, and then suddenly one of the terrorists came right past me shouting, ‘Allahu Akhbar!’ I heard the shots — one, two, three — and was just praying to God that he would save us,” Amos said.

Israel police spokesman Micky Rosenfeld said five other people were wounded in the attack, including the police officer who later died.

“What I saw was horrifying,” said Avi Nefoussi, a paramedic who was among the first to enter the synagogue after the attackers were killed. “I saw several bodies lying on the floor — some were people that I knew — and two people badly injured from gunshots.”

Mirit Sandori, a Har Nof resident who works at a supermarket, said she was shocked but not surprised. “We have no security in this neighborhood, and the situation has been tense in Jerusalem for a long time,” said Sandori, who said she works with Palestinians from East Jerusalem in the supermarket. “Lately, they have been looking at us with cold eyes, eyes of hate.”

President Obama condemned the attack and called on all sides to lower tensions.

“Innocent people who had come to worship died in the sanctuary of a synagogue,” Secretary of State John F. Kerry said shortly after the attack, his voice quavering. He said the victims “were hatcheted, hacked and murdered in that holy place in an act of pure terror.”

Kerry echoed Netanyahu by referring to the killings as “a pure result of incitement.”

The attack was reminiscent of the Palestinian intifadas, or uprisings, of past years and appeared likely to inflame a city strained by tensions.

Many Palestinians were deeply angered by Israel’s decision last month to suspend access to the Al-Aqsa mosque in an area known as the Temple Mount to Jews and the Noble Sanctuary to Muslims, a holy site to both religions.

The Israeli restrictions — which are now lifted — came after a Palestinian gunman tried to kill an Israeli American activist who wants Jews to be allowed to pray at the site. Jews and Christians are normally allowed to visit the area as tourists. But they are banned from praying, singing or making religious displays.

Weeks of unrest have followed. Any fresh crackdowns in East Jerusalem — such as home demolitions — could touch off more street battles in the area.

In Jabel Mukaber, where the two Palestinian assailants lived, concrete barricades, smoldering tires and rocks lay strewn along the main road, evidence of clashes between residents and Israeli police early Tuesday.

Mourners gathered around the family of the attackers, one of whom worked in a supermarket near the synagogue, according to Israeli news reports.

“We are against the killing of innocent people on both sides, but Al-Aqsa mosque is a red line that should not be crossed,” said Ala Abu Jamal, a cousin of the attackers. “It will make anyone ready to sacrifice their lives, regardless of the price.”

Sufian Taha in Jerusalem, Daniela Deane in London, and Brian Murphy, Michelle Boorstein, Debbi Wilgoren and Carol Morello in Washington contributed to this report.