“This is part of the same pattern inspired by Islamic State, by ISIS, that we saw first in France, then in Germany and now in Jerusalem. This is part of the same ongoing battle against this global scourge of the new terrorism,” he added.
Mr. Netanyahu has often made the comparison between local attacks against Israelis and those in the rest of the world, though the attacks in Israel are more broadly viewed as being more connected to the Israeli-Palestinian conflict.
While the Israeli security services have described a few Palestinian attackers as having been inspired by the ideology of the Islamic State, no direct links have been established between them and the organization.
The attack on Sunday occurred on the Armon Hanatziv Promenade, a popular tourist spot between East Jerusalem and West Jerusalem that offers sweeping views of the Old City.
The four soldiers killed were Erez Orbach, 20, from Alon Shvut, in the West Bank; Yael Yekutiel, 20, from Givatayim, near Tel Aviv; Shir Hajaja, 22, from Maale Adumim in the West Bank; and Shira Tzur, 20, from Haifa.
The violence ended several months of relative calm in the contested city, after a period of frequent stabbings, shootings and car attacks.
It also underlined the volatility of the situation at a time when President-elect Donald J. Trump has promised to move the United States Embassy to Jerusalem from Tel Aviv, a potentially explosive step that American administrations have avoided for decades. Palestinian officials say it would destroy the chances of any peace process by prejudging the outcome, and some have said it would constitute a declaration of war against Palestinians.
Mahmoud Abbas, the president of the Palestinian Authority in the West Bank, said on Friday that the Palestinians would view any such change in the status quo in Jerusalem as the crossing of a red line. Mosque preachers addressed the proposed embassy move in their sermons during Friday prayers, apparently on the instruction of the Palestinian Authority.
The Palestinians demand East Jerusalem as the capital of a future Palestinian state. Israel captured the area from Jordan in the 1967 war and claims sovereignty there.
Hamas, the Islamic militant group that holds sway in Gaza, praised Sunday’s attack, without taking responsibility for it. Fawzi Barhoum, a Hamas official, described it as a “courageous and heroic operation.” In Gaza City, people were handing out sweets to passers-by in celebration.
Nickolay Mladenov, the United Nations special coordinator for the Middle East peace process, condemned the attack in a statement. “It is reprehensible that some choose to glorify such acts, which undermine the possibility of a peaceful future for both Palestinians and Israelis,” he said. “There is nothing heroic in such actions.”
The Palestinian official news agency, WAFA, identified the driver of the truck as Fadi Ahmad Al-Qunbar, 28, a resident of the nearby Palestinian neighborhood of Jabel Mukaber in East Jerusalem. Ribhi Ewiysat, a resident of the neighborhood, said that a large number of Israeli security forces had entered the area and were at the attacker’s house.
Chaim Newman, a tour guide who was accompanying the group of soldiers at the scene, told Israel Radio, “The soldiers got off the bus, and we were getting organized when suddenly the truck came with great speed and rammed into the group.”
“Civilians and soldiers began shooting, and this prevented a worse tragedy,” he added. “He rammed them a number of times, going into reverse and forward in order to hurt more people.”
Chen Lendi Sharon, a paramedic from the Magen David Adom ambulance service, said there was “chaos on the scene” when she arrived. “I saw a truck that rammed youngsters getting off the bus next to the Armon Hanatziv observation point.”
Ms. Lendi Sharon said that at least 10 people were trapped under the bus or were lying on the grass by the road.
The attack occurred aroundut 1:30 p.m. Dozens of soldiers were getting off buses at the site as part of a routine educational tour of Jerusalem. Aged 18 to 21, they were cadets from an officers’ course, Israel Radio reported.
About two hours after the attack, the truck, a white flatbed with a crane on the back, remained at the scene and an ambulance was still removing bodies. Dovy Meyer, a spokesman for the United Hatzalah ambulance service who was at the scene, said that around 100 soldiers had been milling about when the attack occurred.
A spate of deadly stabbings, shootings and car attacks began in October 2015 and quickly spread from Jerusalem and the West Bank to cities around Israel. More than 30 Israelis and two American visitors were among those killed in the attacks. More than 240 Palestinians have been killed during that period, many of them while carrying out or intending to carry out attacks, according to Israeli officials.
Several attackers have come from the Jabel Mukaber neighborhood. Mr. Netanyahu said the neighborhood had been “encircled” by security forces on Sunday.