JERUSALEM — The Orthodox Jewish men were facing east, to honor the Old City site where the ancient temples once stood, when two Palestinians armed with a gun, knives and axes burst into their synagogue Tuesday morning, shouting “God is great!” in Arabic. Within moments, three rabbis and a fourth pious man lay dead, blood pooling on their prayer shawls and holy books.

The assailants, cousins from East Jerusalem, were killed at the scene in a gun battle with the police that wounded two officers; one died of his injuries Tuesday night. Politicians and others around the world condemned the attack and the rising religious dimension of the spate of violence, which has been attributed mainly to a struggle over the very site the victims were praying toward.

“The murderers for today’s outrageous acts represent the kind of extremism that threatens to bring all of the Middle East into the kind of spiral from which it’s very difficult to emerge,” President Obama said from the White House. “But we have to remind ourselves that the majority of Palestinians and Israelis overwhelmingly want peace and to be able to raise their families knowing they’re safe and secure.”

The 7 a.m. invasion of a synagogue complex that is the heart of community life in the ultra-Orthodox neighborhood of Har Nof, in West Jerusalem, was the deadliest attack on Israeli civilians in more than three years and the worst in the city since 2008, when eight students were slain at a yeshiva. It brought to 11 the number of Israelis — including a baby, a soldier and a border police officer — killed in the past month.