A Palestinian stabbed two Israeli soldiers outside a West Bank settlement before one of them fatally shot the assailant, the Israeli military said.

One of the soldiers was critically wounded by a stab wound to the neck while the other was lightly hurt before he opened fire and killed the attacker. Both soldiers were taken to hospital.

Israel saw a wave of similar attacks in the West Bank and Jerusalem towards the end of last year, but the violence has mostly subsided and the current Jewish Passover holiday has been relatively quiet thus far.

Palestinians demand the West Bank, which Israel captured from Jordan in the 1967 war, as part of their future state and object to the Israeli presence there. Militants often target soldiers and Jewish settlers there, attacking them with gunfire, knives and stone throwing.

Cabinet minister Naftali Bennett, of the nationalist Jewish Home party, praised the wounded soldier’s quick response.

“This should be the fate of anyone who harms innocent Jews,” he said. “This is how such a serious incident must end.”

It comes as the Israeli military finally admitted to killing a Spanish UN peacekeeping soldier in Lebanon in January.

Cpl Francisco Javier Soria Toledo, 36, one of 10,000 UN soldiers in the region, was hit by Israeli artillery following a Hezbollah attack which killed two Israeli soldiers. The IDF said there had been no intention to harm UN troops.