Three Israelis have been shot dead by a Palestinian at the entrance to the Jewish settlement of Har Adar in the occupied West Bank, Israeli police say.
The gunman, a 37-year-old from a nearby village, was also shot and died later.
Israeli Prime Minister Benjamin Netanyahu blamed the attack on Palestinian incitement.
It came as Donald Trump's Middle East envoy Jason Greenblatt arrived in Jerusalem to try to revive Israel-Palestinian peace talks.
The White House has tried to lay the groundwork for a resumption of negotiations since Donald Trump took office in January, but there has been no sign of progress.
Peace talks between the two sides broke down amid acrimony in April 2014.
Police say the gunman, identified in Israeli media as Nimer Jamal, struck after he raised suspicions of security personnel at a rear gate at Har Adar.
He shot his victims - two security guards and a border policeman - at close-range and seriously wounded another person, before being shot by security forces.
The gunman was a father-of-four who had an Israeli permit to work in Jewish settlements along the boundary of the West Bank, Israel's internal security agency said.
He came from the village of Beit Surik, about a mile east of Har Adar.
The area is about 18km (11 miles) north-west of Jerusalem.
No group has taken responsibility for the attack, although Gaza-based Palestinian militant organisations Hamas and Islamic Jihad welcomed it.
The head of the Information Office of Fatah, the political faction of Palestinian President Mahmoud Abbas, said Israel bore responsibility for the attack, because of its "continuous aggression" against the Palestinians.
Israeli Prime Minister Netanyahu said the attacker's home would be demolished and relatives' work permits revoked. He called on Mr Abbas to condemn the attack unequivocally.
Wave of attacks
About 36,000 Palestinians have permits to work in Jewish settlements, where security to guard against attacks is tight.
The issue of settlements is one of the most contentious between Israel and the Palestinians, who see them as an obstacle to peace.
More than 600,000 Jews live in about 140 settlements built since Israel's 1967 occupation of the West Bank and East Jerusalem. The settlements are considered illegal under international law, though Israel disputes this.
Tuesday's attack is the latest in a wave of stabbings, shootings and car-rammings of Israelis predominantly by Palestinians or Israeli Arabs since late 2015.
Since then, some 50 Israelis and five foreign nationals have been killed in such attacks in Israel and the Occupied Territories.
Around 300 Palestinians - most of them assailants, Israel says - have also been killed in that period, according to AFP news agency. Others have been killed in clashes with Israeli troops.
Israel says Palestinian incitement has fuelled the attacks. The Palestinian leadership has blamed frustration rooted in decades of Israeli occupation.