Three Israelis were killed and 16 injured after two Palestinian gunmen opened fire at a crowded bus stop in West Jerusalem, Israeli police say.
Video showed the attackers getting out of a car on a highway and shooting at people with a rifle and a pistol.
Off-duty soldiers and a civilian at the scene killed the gunmen, who police said were from occupied East Jerusalem.
Hamas claimed the pair as its members and said the attack was a response to Israeli "crimes" in Gaza and elsewhere.
It came hours after the Palestinian armed group - which Israel, the UK, US and other Western powers class as a terrorist organisation - agreed with Israel to extend a truce in Gaza for a seventh day and allow another exchange of Israeli hostages for Palestinian prisoners.