Israel's Supreme Court has ruled that the government must consider re-routing part of the controversial West Bank barrier it is building.
The barrier is part-fence, part-wall depending on Israeli security needs
It follows complaints from Palestinian villagers near the northern town of Qalqilya that the barrier cuts them off from the rest of the West Bank.
The court has ordered the government to consider other options for the route.
But it also rejected last year's world court ruling that the barrier was illegal and should be dismantled.
Israel says its 600km (370 mile) structure is needed to stop suicide attacks, but Palestinians call it a land grab.
The Israeli Supreme Court says the world court ruling was flawed as it did not consider Israel's security needs.
The government had already said it would not abide by the non-binding international ruling and has continued erecting the barrier on occupied Palestinian land.
Struggle for survival
The unanimous decision by the nine-judge panel orders the construction to be re-routed near the settlement of Alfei Menashe, which lies about six kilometres (four miles) inside the West Bank.
The court ruled that "the state must within a reasonable period reconsider the various fence route alternatives at Alfei Menashe while examining security alternatives which cause less injury to the lives of the residents of the villagers in the enclave".
The villagers' petition had said nearly every Palestinian in the Alfei Menashe enclave had lost their job.
"Their struggle for survival obligates them to choose between illegal infiltration into Israel and occasional work at starvation wages... as servants to the settlers," it said.
It is the second time Israel's judiciary has ordered the re-routing of a part of the barrier.
Correspondents say the construction of the barrier - which is more than half completed - remains a source of tension with the Palestinians following the evacuation of Jewish settlements in Gaza.
In places it cuts deep into the West Bank in order to include Jewish settlements like Alfei Menashe on the western, "Israeli" side.
Lawyer Michael Sfard for the villages said the court's decision could affect several other sections of the barrier, even though it contradicts the world court ruling.
"It says that some parts may be legal... but at the same time those parts which severely violate Palestinian rights are not legal and the state will have to change the route in huge parts of the fence," he said.
The Israeli authorities say it is a purely temporary security measure which can be removed as part of any future peace deal, but critics say it is intended as a future border, drawn unilaterally by Israel to keep large swathes of the West Bank.
Palestinian campaigners say that 16% of the Arab population in will be cut off from from Palestinian territory by the West Bank barrier and up to 47% of the occupied territory could be annexed by Israel.