Hamas claims the attacker was a member of its group.

Relatives and friends mourn over the grave of Israeli policeman in Jerusalem October 9, 2016.

JERUSALEM, Oct 9 (Reuters) - A Palestinian who was due to begin a prison term in Israel next week went on a shooting spree on Sunday, killing a pedestrian and a police officer in Jerusalem before being shot dead by police, medical and law enforcement officials said.

The incident, near Israel’s national police headquarters, began when shots were fired from a vehicle at people waiting at a tram stop, a police spokeswoman said.

The assailant, who the Palestinian Islamist group Hamas said was a member of its organization, then drove off and was shot dead in an exchange of fire with police, she said.

Medical officials said six people were wounded in the attack, and that two of them, a woman and a police officer, died in hospital. Police identified the assailant as a 39-year-old Palestinian from East Jerusalem.

A spokeswoman for the Israel Prisons Service said the attacker had been ordered by a court to start a four-month jail sentence next week after being convicted of assaulting a police officer.

In the past year, Palestinians, many acting alone and often with rudimentary weapons, have killed at least 35 Israelis and two visiting Americans in attacks.

During that period, at least 220 Palestinians have died in violent incidents in the Israeli-occupied West Bank, East Jerusalem and the Gaza Strip. Of those, 149 were identified by authorities as assailants while others were killed during clashes and protests.

Israel says anti-Israeli incitement by Palestinian officials and on social media networks is stoking attacks.

Palestinian leaders say assailants are acting out of desperation over the collapse in 2014 of peace talks and the expansion of Israeli settlements on occupied land that Palestinians seek for an independent state.