JERUSALEM — A Palestinian fatally stabbed two Israelis as they walked in Jerusalem’s Old City and seriously wounded a toddler and a woman before he was shot and killed by a police officer, police said Saturday.

Jerusalem Police Chief Moshe Edri said the Palestinian “stabbed an Israeli man, his wife and the toddler” multiple times in an alleyway before stabbing another man.

Both Israeli men died of their wounds, he said, adding that the mother and the toddler are in serious condition.

Police spokeswoman Luba Samri said the Palestinian attacker took a gun from one of the wounded men and opened fire at police and tourists.

The attacker was then shot and killed by an Israeli police officer who rushed to the scene. Police later identified the attacker as a 19-year-old from Al Bireh, near Ramallah.

Hamas, the Islamic militant group that rules Gaza, issued a statement praising the attack, which it called, “heroic.”

It was the latest in a series of deadly Palestinian attacks against Israeli civilians. On Thursday, suspected Palestinian gunmen killed an Israeli couple as they drove in the West Bank.