Three Israeli security officers were killed and one was seriously hurt in a terror attack outside the Har Adar settlement near Jerusalem early Tuesday morning, police said.

According to police, the assailant arrived at the rear entrance of the settlement and opened fire on a group of security personnel, including Border Police officers and the community’s private guards, who were opening the entrance to Palestinian workers.

The terrorist, a laborer from the nearby Bayt Surik village, was shot and killed by security forces at the scene, police said.

Get The Times of Israel's Daily Edition by email and never miss our top stories Free Sign Up

The 37-year-old approached the entrance to Har Adar just before 7 a.m. as part of a group of Palestinians who work in the settlement.

He “aroused the suspicion” of officers on the scene, who called for him to stop. The terrorist then took a pistol out of his shirt and shot at the Israelis, before being gunned down, police said.

He killed a Border Police officer and two private security guards, all in their 20s. They all sustained gunshot wounds to the upper body. (Initial reports that they had also been stabbed were incorrect.)

The slain Border Police officer was identified as Solomon Gavriyah, 20, from Be’er Yaakov. He was posthumously promoted to staff sergeant.

One of the security guards killed in the attack, Youssef Ottman, 25, was a resident of the nearby Arab Israeli community of Abu Ghosh. The second was identified as Or Arish, 25, a resident of Har Adar.

The seriously injured victim was identified as Har Adar’s security coordinator. He suffered gunshot wounds to the stomach and chest, and was fully conscious when he was taken to Jerusalem’s Hadassah Hospital Ein Kerem. Upon reaching the hospital, he was taken to an operating room for surgery, a Hadassah spokesperson said.

Police said the terrorist, a father of four, had a legal work permit, making him one of the few Palestinians with such a document to commit a terror attack in recent years. His permit was of a lower level and was only applicable for work inside Israeli settlements, like Har Adar, which lie along the “seam line” between the West Bank and Israel, according to the Shin Bet security service.

He was identified as Nimer Mahmoud Ahmad Jamal. The Shin Bet said he did not have a known history of involvement in terrorist activities.

The security service said Jamal appeared to be suffering from “significant personal and family problems” and that there was a history of violence in the family.

The Shin Bet also noted that the terrorist’s wife left him several weeks ago and moved to Jordan, leaving him with the children.

Before carrying out the attack, he left a note saying he was “a terrible husband” and that his wife had “nothing to do with what will happen,” Israel Radio reported.

In the hours after the attack, security forces raided the attacker’s home. The IDF also said it set up a closure around Bayt Surik, allowing residents to enter freely but exit only for “humanitarian” reasons.

[mappress mapid=”6168″]

Har Adar is located just inside the West Bank, off the main highway leading into Jerusalem from Tel Aviv. The affluent community has not been a common target for terror attacks. One exception was in October 2016, when a Border Police officer was stabbed in the arm near the settlement.

Israel Police Commissioner Roni Alsheich, who arrived at the scene of the attack, said the terrorist “was known to those who greet the workers in the morning.”

He praised the response of security personnel at the scene, saying a border policeman and a policewoman in a nearby jeep opened fire on the attacker, “otherwise he could have entered the town and carried on with his murderous errand.”

Responding to questions about the rarity of attacks from Palestinians with work permits, Alsheich said, “To my regret there is no profile for a terrorist.”

“It could just be someone who is fed up with everything and decides to take out his rage in an attack,” he said, adding, “The incitement [against Israel] is constant.”

Chen Filipovitz, the head of the local council, praised his settlement’s security guards for their quick reaction.

“Our workers and security coordinator worked as needed,” Filipovitz told Channel 2 news after the attack. “It was not inside the community but at the gate where workers enter. There are hundreds of workers who enter every day to work in Har Adar and the surrounding communities.”

The Hamas terror group praised the attack, saying, “Once again Jerusalem proves that it is at the heart of the conflict with the occupation, and that there is no way to get it out of the equation of the conflict.”

The terror attack comes two years after a wave of unrest broke out, mostly in the West Bank and Jerusalem.

The violence had greatly subsided in recent months.

Since September 2015, some 51 Israelis, two visiting Americans, an Eritrean national, a Palestinian man and a British student have been killed in stabbing, shooting and vehicular attacks by Palestinian assailants. In that time, nearly 300 Palestinians and a Sudanese national were killed by Israeli fire, a majority of them attackers, according to authorities.

The Israeli government has blamed the terrorism and violence in part on incitement by Palestinian political and religious leaders, compounded on social media sites that glorify violence and encourage attacks.

Stuart Winer, Dov Lieber, Jacob Magid and agencies contributed to this report.