Embarrassingly for the government, the supreme court, ruling in the case of Bilin village in the Ramallah district, endorsed what critics of the barrier's route have long maintained: that it was drawn by the government in a manner enabling the taking of more land for Israeli settlements rather than according to strict security or topographical logic.
The justices ordered that a new route be drawn "that causes less harm to the residents of the village".
Bilin residents had argued that the barrier route prevented them from reaching half of their fields and orchards. The government responded that the route was necessary in order to protect an as yet to be constructed section of the Matityahu Mizrach settlement.
But the judges rejected this, writing that the extension had not been constructed yet and might not be in the future. The ruling touched off celebrations in Bilin, which more than any other place has come to symbolise protest against the barrier because of weekly demonstrations over the last two-and-a-half years, including local residents, Israeli left-wingers and young internationals.
The demonstrations have invariably turned violent, with police using rubber-coated metal bullets and tear gas, and villagers throwing stones.
Jubilant villagers poured out of houses and schools and headed towards the fence, where army jeeps gathered as the crowd grew. "They demolished the Berlin wall, we want to tear down the Bilin wall," they chanted. Abdullah Abu Rahme, a village activist, called the decision "wonderful" but another leader of the Friday protests, Basil Yasin, branded the ruling only a "partial success."
"This does not return all the land to Bilin," he said. "The barrier is not only on Bilin land. Bilin is just a part of the Palestinian homeland and the barrier continues to take a great share of this homeland."
Israel began building the barrier in 2002, saying it was necessary to halt infiltration by Palestinian suicide bombers. Although much of the barrier is close to the old border between Israel and the West Bank, at some points it snakes deep into the occupied territory, enfolding Israeli settlements while breaking the Palestinian areas up into disjointed enclaves.
The International Court of Justice ruled the barrier illegal in 2004 for being built on occupied territory and ordered it to be dismantled.
Yonatan Pollack, an activist in a dovish Israeli group that demonstrated alongside Bilin residents, said: "After two years of arrests and injuries, we are ecstatic to have this ruling."
In other developments, Israeli vice-premier Haim Ramon proposed cutting off electricity, fuel and water supplies to the Gaza Strip in response to continued Palestinian rocket attacks. Defence ministry officials said they were studying the "feasibility and legality" of limiting electricity and water to Gaza, which is ruled by the militant Islamic group Hamas.
Meanwhile, a Palestinian boy aged eight in the West Bank city of Nablus was seriously wounded by a rubber-coated metal bullet fired by Israeli troops, Palestinian hospital officials said.