JERUSALEM — A Palestinian man fatally shot two Israeli co-workers and injured a third in an Israeli-run factory in the occupied West Bank on Sunday, an attack that Israeli officials described as terrorism.

The killings shattered the calm in an industrial park long praised by Israelis as a symbol of peaceful coexistence.

Hamas, the Islamic militant group that controls Gaza, praised the attack without taking responsibility for it, calling it a “heroic operation.” Hamas said the shooting had been a “natural response to the crimes of the Israeli occupation against the rights of our people, in all the Palestinian lands.”

The Islamic Jihad group in Gaza also praised the attack.

The gunman, identified by the Israeli authorities only as Ashraf Naalwa, 23, a resident of the West Bank, was captured on security cameras fleeing the scene. Mr. Naalwa, an electrician, had not shown up for work in recent days and might have harbored grievances against his employers, according to other workers in the industrial park, near the settlements of Barkan and Ariel in the central West Bank.