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 succumbed to 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.
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.
More From This Section
On Thursday, suspected Palestinian gunmen killed an Israeli couple in front of their children as they drove in the West Bank.
Multiple shots killed Eitam and Naama Henkin, residents of the Jewish West Bank settlement of Neria. Their four young children, including a four-month-old infant, were in the back seat of the car during the shooting but were unharmed.
Israel forces were later deployed in the West Bank hunting for the gunmen.