JERUSALEM — A Palestinian driver plowed a truck into a group of Israeli soldiers as they were getting off a bus in Jerusalem on Sunday afternoon, killing four and injuring 17 others, according to the police and witnesses.

The police called the episode an act of terrorism. Micky Rosenfeld, a police spokesman, said the attacker had been shot, and the police released images showing the truck’s windshield riddled with bullet holes.

The dead included three female soldiers and one male soldier, the Israeli military confirmed. Several people were hospitalized, some with critical injuries.

Prime Minister Benjamin Netanyahu visited the scene of the attack and said the perpetrator was “by all indications a supporter of the Islamic State.”