Shmuel Ben Ruby, Jerusalem police spokesman, said: "One terrorist infiltrated the Mercaz Harav seminary and opened fire in all directions.
"[He] was killed in an exchange of fire, and apparently he had an explosives belt."
Aharon Franco, another police official, said that the assailant came from Jabel Mukaber, a neighbourhood in east Jerusalem.
Israel captured east Jerusalem in the 1967 Middle East war and immediately annexed the area.
In contrast to Palestinians in the West Bank, Arab residents of Jerusalem have Israeli identification cards, allowing them free movement between Israel and the West Bank.
Al Jazeera's Ayman Mohyeldin, reporting from the scene of the attack, said that questions will be raised as to how the assailants passed through the many security checks situated in the area.
"There are numerous checkpoints throughout the city," he said.
"The deaths will ultimately raise many questions regarding the apparent lapse in surveillance around the school."
A spokesman for the Israeli foreign ministry said that those responsible for the shooting are "killing chances for peace".
"The terrorists attack a school and innocent people," Arye Mekel said.
"They are trying to kill the chances for peace. We will continue our fight against terrorists."
'Talks to continue'
Mekel, however, said that Israel will continue to hold US-backed peace talks with the Palestinians despite the incident.
For his part, the Palestinian president condemned the seminary attack.
Saeb Erekat, an Abbas aide, said: "President Mahmoud Abbas condemns the attack in Jerusalem that claimed the lives of many Israelis and he reiterated his condemnation of all attacks that target civilians, whether they are Palestinians or Israelis."
By contrast, in the Gaza Strip people fired in the air to celebrate the attack, which occurred three days after Israel ended a military offensive in the Hamas-run territory that killed at least 120 people.
Hamas labelled the shooting as "heroic".
Sami Abu Zuhri, a spokesman for the group, said: "This heroic attack in Jerusalem is a normal response to the crimes of the occupier and its murder of civilians."
Taher al-Nunu, another spokesman, blamed the attack on Ehud Olmert, the Israeli prime minister, and Ehud Barak, the defence minister.
"We have warned before about the responsibility of the escalation in Gaza and warned of Palestinian anger," Nunu said.
Al Jazeera's Jacky Rowland, reporting from Gaza, said that the atmosphere in the enclave is one at both elation and anxiety.
"While many have praised the attack, the people of Gaza feel that this incident will not go unpunished," she said.
Rowland said that the shooting will be a psychological blow to many Israelis.
"There area is a cultural and ideological centre of Jerusalem. People will definitely feel vulnerable that an attack took place in a deeply religious area."
Separately, Hezbollah's Al-Manar TV claimed that the perpetrators of the attack were members of the "Phalange of Free Men of Galilee - Groups of the Martyr Imad Moghaniyah and Martyrs of Gaza", a previously unknown group.
The claim was made in a tag line running across the bottom of the screen.
Imad Moghaniyah was a top Hezbollah commander assassinated in a bombing in Damascus, the Syrian capital, on February 12.
The Lebanese Shia Muslim group blamed the killing on Israel and threatened attacks in revenge.
Israel denied any involvement in Moghaniyah's killing.