Militant group the Popular Front for the Liberation of Palestine (PFLP) has claimed responsibility for the deadly attack on a Jerusalem synagogue.

Two Palestinians armed with knives, axes and guns attacked worshippers praying inside a synagogue in Jerusalem's ultra-Orthodox Har Nof neighbourhood, killing four.

They were subsequently shot dead in a gunfight with security forces that rushed to the scene. Two police officers and six other people were injured.

Police confirmed the assailants were two Palestinians from east Jerusalem, with media reports identifying them as Ghassan and Uday Abu Jamal, two cousins from the Jabel Mukaber neighbourhood.

PFLP's armed wing, the Abu Ali Mustafa Brigades said the two were its members, but did not say whether they had been instructed to launch the raid or acted of their own initiative.

PFLP is a far-left nationalist group that has been blamed for attacks on Israelis in the past.

Footage showed wounded worshippers being assisted by paramedics, and a bloodied meat cleaver lay nearby. Initially, police had described the weapons used as knives and axes.

"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.

Yosef Posternak, who was at the synagogue at the time of the attack, told Israel Radio that about 25 worshippers were inside when the attackers entered.

"I saw people lying on the floor, blood everywhere. People were trying to fight with (the attackers) but they didn't have much of a chance," he said.

Footage released by the Israeli government showed blood-soaked prayer books and prayer shawls on the floor of the synagogue. A pair of glasses lay under a table, from which blood was dripping. A set of phylacteries hung off the table. A photo in Israeli media showed a body on the floor, covered with a prayer shawl.

Jerusalem synagogue attacks
Blood trails are seen on the floor near covered bodies at the scene of an attack at a Jerusalem synagogue Reuters

Hamas, the militant Palestinian group that runs the Gaza Strip, praised the attack.

Israel's police chief suggested the attack was not planned in advance by the group.

"These are individuals who decide to do horrible acts. It's very hard to know ahead of time about every such incident," said Yohanan Danino.

Hamas spokesman Sami Abu Zuhri hailed the killings on Facebook saying they were in retaliation for the death Yusuf Hassan al-Ramouni, a 32-year-old bus driver.

"Jerusalem attack is a reaction to the execution of the martyr al-Ramouni and the ongoing Israeli crimes at al-Aqsa," Hamas Spokesman Sami Abu Zuhri wrote on Facebook. "Hamas calls for the continuation of acts of revenge".

Al-Ramouni was found hanged inside his vehicle from a thin cord at the beginning of his route in a district close to both Jewish settlements and Palestinian neighbourhoods.

Israeli police said an autopsy carried out, in the presence of a Palestinian pathologist chosen by the family, confirmed it was suicide.

Nevertheless al-Ramouni family claimed he was killed, with Palestinian media quoting witnesses as saying the father of two was lynched by Jewish settlers.

The synagogue attack was the deadliest in Jerusalem in years and comes amid heightened tensions in the Holy City.

Palestinian President Mahmoud Abbas condemned the incident. "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," his office said in a statement.