The assailant, whose name was not released because of a court order, was supposed to report to an Israeli jail on Sunday morning to serve a four-month term for assaulting a police officer in 2013, according to Israeli and Palestinian news reports. He had been jailed in the past for security offenses and incitement to violence, the reports said.

A day before the shooting, he told Maan, an independent Palestinian news agency, that he intended to report to prison in Ramla, a city in central Israel, at 10 a.m. on Sunday. Instead, he apparently headed to the area around the police headquarters in Jerusalem.

The Magen David Adom Israeli ambulance service got the first call about the shootings at 10:12 a.m. In addition to the two deaths, it said, three people were wounded by gunshots and two women were slightly injured when the assailant’s car hit their vehicle as he tried to flee.

Hamas, the Islamic militant group that controls the Palestinian coastal territory of Gaza, praised the attack and described the gunman as “one of ours.”

Al Quds, the Hamas-affiliated television station, broadcast a video that it said was exclusive to the channel and that it described as the perpetrator’s last words. It was not clear when or where the video had been filmed.