At least four Israelis have been killed and eight injured as two menarmed with a pistol, knives and axes attacked a West Jerusalem synagogue, police say.
The attackers - Palestinians from East Jerusalem - were shot dead.
There have been several deadly attacks and clashes in Jerusalem recently amid tension over a disputed holy site.
Israeli Prime Minister Benjamin Netanyahu has vowed to respond "with a heavy hand" to the attack - the deadliest in Jerusalem in six years.
He blamed "incitement" by Hamas and Palestinian President Mahmoud Abbas, and said the international community had ignored their actions.
Hamas and Mr Abbas's Fatah party - rival Palestinian factions - agreed to form a unity government earlier this year, a move denounced at the time by Israel.
Mr Abbas's office issued a statement saying: "The presidency condemns the attack on Jewish worshippers in their place of prayer and condemns the killing of civilians no matter who is doing it."
The Abu Ali Mustafa Brigades, the military wing of the Popular Front for the Liberation of Palestine, says it carried out the synagogue attack.
Militants from the far-left-wing Palestinian nationalist group have been behind many previous attacks on Israelis.
Hamas and another militant group, Islamic Jihad, praised the attack. Israel has designated both groups as terrorist organisations.
Visiting London, US Secretary of State John Kerry said the act of "pure terror... simply has no place in human behaviour". His UK host Philip Hammond condemned "the appalling attack".