JERUSALEM — A Palestinian gunman on Tuesday killed three Israeli security men and critically wounded a fourth outside a West Bank settlement before being shot dead, in one of the deadliest attacks of a two-year spate of violence.

Israeli officials said the attacker was a 37-year-old father of four, with a valid work permit in Israel and a troubled personal life who appeared to have acted alone.

The attack comes at a tense period amid the Jewish high holidays and is likely to complicate the mediation efforts of U.S. peace envoy Jason Greenblatt, who just arrived in the region for meetings with Israeli and Palestinians leaders.

Speaking at his weekly Cabinet meeting, Israeli Prime Minister Benjamin Netanyahu said the attack was partially a result of systematic Palestinian incitement and said he expected Palestinian President Mahmoud Abbas to “condemn this attack and not try to justify it.”

Police spokeswoman Luba Samri said the attacker approached the back gate entrance of the Har Adar settlement, hiding among dozens of Palestinian day laborers who were being checked by security forces. When police asked him to stop, he opened fire at close range before being shot dead by security forces, Samri said.

The casualties were identified as Solomon Gavria, a 20-year-old policeman, and two private security guards — Yousef Othman and Or Arish, who were both 25. The Magen David Adom medical service said that in addition to the three killed, a fourth Israeli man, in his early 30s, was hospitalized in critical condition.

Dr. Alon Pikarsky, head of surgery at Hadassah Medical Center in Jerusalem, later said the man was in stable condition after undergoing surgery to remove two bullets.

Har Adar is an upscale community west of Jerusalem, straddling the seam line between the West Bank and Israel proper and known for its good relations with its Arab neighbors — an unusual target in the wave of violence that Israel has been coping with over the past two years.

Shay Retter, the head of Har Adar’s security committee, said 100 to 150 Palestinian laborers typically enter the community every day for work. Local residents said they knew the attacker from previous work he had done and were shocked to hear about the attack. The military imposed a closure on the nearby Palestinian village of Beit Surik, the home of the attacker.

Israeli Defense Minister Avigdor Lieberman said he saw no difference between Palestinian terrorism and radical Islamic terrorism targeting sites in Europe and elsewhere.

“Before talking about any kind of negotiations, the world must demand of the Palestinian Authority to stop its incitement and encouragement of terror,” he said, alluding to Greenblatt’s visit and his goal of securing concessions for the Palestinians.

Minister of Intelligence Israel Katz was even blunter.

“The attack is also a message to special U.S. envoy Greenblatt,” he said. “Israel’s security was and yet remains the supreme consideration in the government’s policy, and is above any other consideration of improving and easing the lives of the Palestinians.”

Netanyahu pledged that as a punitive measure, the attacker’s home would be demolished and working permits of his extended family would be revoked.

But Israel’s internal Shin Bet security service downplayed ideology as a motive, saying the attacker was plagued with personal issues.

The attacker was identified as Nimr Mahmoud Ahmed Jamal, and the Shin Bet said its preliminary investigation indicated there was significant violence in his family. His wife had recently fled to Jordan to escape his abuse and left him with their four children, it said.

In a message to his estranged wife that he asked her to share 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.”

Since September 2015, Palestinians have killed 51 Israelis, two visiting Americans and a British tourist in stabbings, shootings and car-ramming attacks. Several attacks were carried out by individuals struggling with domestic and emotional issues whose acts were subsequently cloaked in nationalism.

During that same time, Israeli forces have killed more than 255 Palestinians. 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.

Israel blames the violence on incitement by Palestinian religious and political leaders compounded on social media sites. Palestinians say the attacks stem from anger and frustration at decades of Israeli rule in territories they claim for a state.

The frequency and intensity of attacks has lessened of late, but Tuesday’s shooting, coming between the Jewish new year and the somber Yom Kippur, threatened to ignite them anew. The latest wave of violence broke out during the 2015 holiday season.

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.