JERUSALEM — A gunman entered the library of a rabbinical seminary and opened fire on a crowded study session Thursday, killing eight people and wounding nine before he was slain, police said.
Hamas militants in the Gaza Strip praised the operation in a statement, and thousands of Palestinians took to the streets of Gaza to celebrate.
The day's violence, which also included a deadly ambush of an army patrol near Israel's border with Gaza, was likely to complicate attempts by Egypt to arrange a truce between Israel and Palestinian militants.
Israeli government spokesman Mark Regev and moderate Palestinian President Mahmoud Abbas condemned the shooting. But Regev said the Palestinian government must take steps against the extremists — not just denounce their attacks.
"Tonight's massacre in Jerusalem is a defining moment," he said. "It is clear that those people celebrating this bloodshed have shown themselves to be not only the enemies of Israel but of all of humanity."
Secretary of State Condoleezza Rice, who just Wednesday persuaded Abbas to return to peace talks with Israel, called the attack an "act of terror and depravity."
Israeli defense officials said the attacker came from East Jerusalem, the predominantly Palestinian section of the city. Jerusalem's Palestinians have Israeli ID cards that give them freedom of movement in Israel.
Police spokesman Micky Rosenfeld said the attacker walked through the seminary's main gate and entered the library, where witnesses said some 80 people were gathered. He carried an assault rifle and pistol, and used both weapons.
Witnesses described a terrifying scene during the shooting, with the high-school age students jumping out windows to escape.
One student, Yitzhak Dadon, said he shot the attacker twice in the head. "I laid on the roof of the study hall, cocked my gun and waited for him. He came out of the library spraying automatic fire," he said.
Police said an Israeli soldier then shot the man dead. After the shooting, hundreds of seminary students demonstrated outside the building, screaming for revenge and chanting, "Death to Arabs."
About the same time, roughly 7,000 Gazans marched in the streets of Jebaliya, firing in the air in celebration, and visited homes of those killed and wounded in the last Israeli incursion.
Hamas stopped just short of claiming responsibility for the Jerusalem shootings. "We bless the operation. It will not be the last," Hamas said in a statement sent to reporters by text message.
The attack came on the same day Egyptian officials were trying to mediate a truce between Palestinian militants in Gaza and Israel. The proposal, backed by the United States, would stop rocket fire on Israel in exchange for an end to Israeli attacks on militants and the resumption of trade and travel from Gaza.
An Israeli official confirmed that Israel is open to the idea of letting guards from Abbas' moderate Fatah movement oversee Gaza's borders — one of the main tenets of the truce idea. But the Israeli spoke before the shooting, and it was not immediately known whether his country's position would change.