JERUSALEM - A Palestinian gunman killed three Israelis and critically wounded a fourth outside a West Bank settlement before he was shot dead Tuesday, dealing a new blow to the efforts by President Donald Trump's Middle East envoy to restart long-stalled peace talks.

The early morning shooting, which took place as Palestinian labourers were lined up to enter the Har Adar settlement, was one of the deadliest attacks in a two-year spasm of violence. While Israeli leaders condemned the attack, the gunman was identified as a lone assailant motivated by personal problems, leaving Israel with limited options for responding.

Trump's envoy, Jason Greenblatt, said he was “horrified” by the attack. “All must stand against terror!” he wrote on his Twitter page.

Greenblatt has been shuttling between the sides in search of a formula for restarting peace talks between Israel and the Palestinians. But eight months after Trump took office, there has been no tangible progress, and the administration has said it needs more time to draw up a proposal.

Greenblatt, who arrived in the region Monday, is scheduled to meet with Israeli and Palestinian leaders in the coming days.

He is sure to get an earful from the Israeli side, which has long accused Palestinian President Mahmoud Abbas of inciting violence and complained about his practice of giving stipends to the families of people killed in clashes with Israel, even attackers.

“Before talking about any kind of negotiations, the world must demand of the Palestinian Authority to stop its incitement and encouragement of terror,” said Defence Minister Avigdor Lieberman.

Abbas' office remained silent on the attack. But in the past, while criticizing violence, Abbas has said such attacks are the result of frustration after decades of Israeli occupation.

“Israel holds the responsibility for any Palestinian attack because these attacks come as reactions to the Israeli crimes against our people,” said Munir al-Jaghoub, a midlevel official in Abbas' Fatah party, in a social media post.

Israeli Prime Minister Benjamin Netanyahu urged Abbas “to condemn this attack, not try to justify it.”

He said the attacker's home would be demolished and that permits allowing members of his extended family to enter Israel to work would be revoked. Israeli forces also prevented residents of the attacker's nearby village, Beit Surik, from exiting, and arrested three of his brothers.

Such tactics are standard Israeli responses. But in the past, they have been short-lived, and it is unclear what other options Netanyahu would have.

Both Israelis and Palestinians who knew the attacker, Nimr Mahmoud Ahmed Jamal, including his own family, said they were shocked by the shooting.

“We were surprised when we heard the news this morning, because we had no prior knowledge of anything and we know nothing,” said his uncle, Issa Jamal.

Israel's Shin Bet security service played down ideology as a motive, saying the attacker was plagued by personal issues.

It said its preliminary investigation indicated there was significant violence in his family, adding that his wife had recently fled to Jordan to escape his abuse and left him with their four children.

In a message to his estranged wife that he posted on Facebook, Jamal praised her and called himself a bad husband.

“I was very jealous and I've done terrible things in the community,” he wrote. “I ask you to forgive me and take care of the kids.”

Har Adar is an upscale community west of Jerusalem, straddling the line between the West Bank and Israel. The settlement is known to have good relations with its Palestinian neighbours and typically allows in 100 to 150 Palestinian labourers each morning.

Residents said Jamal was well-known and well-liked.

Drora Bardichev, said Jamal had worked in her home for four years and that he was “almost like family.” She said he had talked about his family troubles and his wife leaving for Jordan.

“I cannot believe that it is him,” she tearfully told Channel 10 TV. “He was our friend. I can't believe it is him. I am in total shock.”

Police spokeswoman Luba Samri said the attacker approached the back gate entrance of Har Adar, among dozens of Palestinian day labourers who were being checked by security forces. Police said he was acting suspiciously and asked him to stop, and he then opened fire at close range before being shot dead.

The dead were identified as Solomon Gavria, a 20-year-old policeman, and two private security guards - Yousef Othman and Or Arish, both 25. A fourth man was critically wounded, but listed in stable condition after having two bullets removed.

The victims represented a cross section of Israeli society. Gavria came from a family of Jewish Ethiopian immigrants in southern Israel, Arish was a resident of Har Adar, and Othman lived in Abu Ghosh, a nearby Arab village inside Israel.

Othman's father, Issam, said his son loved everyone.

“There was no difference between Jews and Arabs for him,” he said. “He knew what his role was. It's to guard, to secure both sides ... the Jewish side as well as the Arab side.”

Since September 2015, Palestinians have killed 51 Israelis, two visiting Americans and a British tourist in stabbings, shootings and car-ramming attacks.

While Israel has said Palestinian incitement fueled the attacks, many were carried out by individuals like Jamal who were struggling with domestic and emotional issues and whose acts were subsequently cloaked in nationalism.

In Palestinian society, attackers are often lauded as “martyrs,” and political leaders are cautious about condemning their acts.

Israel has struggled to contain these “lone wolf” attacks because they have not been carried out by organized militant groups.

Gaza's Islamic Hamas rulers praised the attack but stopped short of taking responsibility for it. In a statement, the group called the assault a “heroic operation” that was a “natural response” to Israeli aggression against Palestinians and proved that the Palestinian uprising was still alive.

In Gaza, about 300 Hamas supporters marched Tuesday night to celebrate the attack.

Israeli forces have killed more than 260 Palestinians since 2015. Israel says most of them were attackers and others died in clashes with Israeli forces. Most of the attacks have been stabbings against security forces, primarily in the West Bank.

The frequency and intensity of attacks has lessened in the past year or so, but Tuesday's shooting, coming between the Jewish new year and the sombre Yom Kippur, threatened to ignite them anew. The attacks broke out during the 2015 holiday season.